Package org.hibernate.transaction
Class JTATransaction
java.lang.Object
org.hibernate.transaction.JTATransaction
- All Implemented Interfaces:
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.-
Constructor Summary
ConstructorsConstructorDescriptionJTATransaction(UserTransaction userTransaction, JDBCContext jdbcContext, TransactionFactory.Context transactionContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidbegin()Begin a new transaction.voidcommit()Flush the associated Session and end the unit of work (unless we are inFlushMode.MANUAL.protected UserTransactionGetter for property 'userTransaction'.booleanisActive()Is this transaction still active?voidRegister a user synchronization callback for this transaction.voidrollback()Force the underlying transaction to roll back.voidsetTimeout(int seconds) Set the transaction timeout for any transaction started by a subsequent call to begin() on this instance.booleanCheck if this transaction was successfully committed.booleanWas this transaction rolled back or set to rollback only?
-
Constructor Details
-
JTATransaction
public JTATransaction(UserTransaction userTransaction, JDBCContext jdbcContext, TransactionFactory.Context transactionContext)
-
-
Method Details
-
begin
Begin a new transaction.- Specified by:
beginin interfaceTransaction- Throws:
HibernateException
-
commit
Flush the associated Session and end the unit of work (unless we are inFlushMode.MANUAL. This method will commit the underlying transaction if and only if the underlying transaction was initiated by this object.- Specified by:
commitin interfaceTransaction- Throws:
HibernateException
-
rollback
Force the underlying transaction to roll back.- Specified by:
rollbackin interfaceTransaction- Throws:
HibernateException
-
wasRolledBack
Was this transaction rolled back or set to rollback only? This only accounts for actions initiated from this local transaction. If, for example, the underlying transaction is forced to rollback via some other means, this method still reports false because the rollback was not initiated from here.- Specified by:
wasRolledBackin interfaceTransaction- Returns:
- boolean True if the transaction was rolled back via this local transaction; false otherwise.
- Throws:
TransactionException
-
wasCommitted
Check if this transaction was successfully committed. This method could return false even after successful invocation ofTransaction.commit(). As an example, JTA based strategies no-op onTransaction.commit()calls if they did not start the transaction; in that case, they also reportTransaction.wasCommitted()as false.- Specified by:
wasCommittedin interfaceTransaction- Returns:
- boolean True if the transaction was (unequivocally) committed via this local transaction; false otherwise.
- Throws:
TransactionException
-
isActive
Is this transaction still active? Again, this only returns information in relation to the local transaction, not the actual underlying transaction.- Specified by:
isActivein interfaceTransaction- Returns:
- boolean Treu if this local transaction is still active.
- Throws:
TransactionException
-
registerSynchronization
Register a user synchronization callback for this transaction.- Specified by:
registerSynchronizationin interfaceTransaction- Parameters:
sync- The Synchronization callback to register.- Throws:
HibernateException
-
setTimeout
public void setTimeout(int seconds) Set the transaction timeout for any transaction started by a subsequent call to begin() on this instance.- Specified by:
setTimeoutin interfaceTransaction- Parameters:
seconds- The number of seconds before a timeout.
-
getUserTransaction
Getter for property 'userTransaction'.- Returns:
- Value for property 'userTransaction'.
-