org.hibernate.transaction

Class JTATransaction

Implemented Interfaces:
Transaction

public class JTATransaction
extends java.lang.Object
implements Transaction

Transaction implementation based on transaction management through a JTA UserTransaction. Similar to CMTTransaction, except here we are actually managing the transactions through the Hibernate transaction mechanism.

Instances check to see if there is an existing JTA transaction. If none exists, a new transaction is started; if one exists, all work is done in the existing context. The following properties are used to locate the underlying UserTransaction:

Author:
Gavin King

Constructor Summary

JTATransaction(InitialContext context, String utName, JDBCContext jdbcContext, TransactionFactory.Context transactionContext)

Method Summary

void
begin()
void
commit()
protected UserTransaction
getUserTransaction()
Getter for property 'userTransaction'.
boolean
isActive()
void
registerSynchronization(Synchronization sync)
void
rollback()
void
setTimeout(int seconds)
boolean
wasCommitted()
boolean
wasRolledBack()

Constructor Details

JTATransaction

public JTATransaction(InitialContext context,
                      String utName,
                      JDBCContext jdbcContext,
                      TransactionFactory.Context transactionContext)

Method Details

begin

public void begin()
            throws HibernateException
Specified by:
begin in interface Transaction

commit

public void commit()
            throws HibernateException
Specified by:
commit in interface Transaction

getUserTransaction

protected UserTransaction getUserTransaction()
Getter for property 'userTransaction'.
Returns:
Value for property 'userTransaction'.

isActive

public boolean isActive()
            throws TransactionException
Specified by:
isActive in interface Transaction

registerSynchronization

public void registerSynchronization(Synchronization sync)
            throws HibernateException
Specified by:
registerSynchronization in interface Transaction

rollback

public void rollback()
            throws HibernateException
Specified by:
rollback in interface Transaction

setTimeout

public void setTimeout(int seconds)
Specified by:
setTimeout in interface Transaction

wasCommitted

public boolean wasCommitted()
            throws TransactionException
Specified by:
wasCommitted in interface Transaction

wasRolledBack

public boolean wasRolledBack()
            throws TransactionException
Specified by:
wasRolledBack in interface Transaction