Package org.hibernate.transaction
Class CMTTransaction
java.lang.Object
org.hibernate.transaction.CMTTransaction
- All Implemented Interfaces:
Transaction
Implements a basic transaction strategy for CMT transactions. All work is
done in the context of the container managed transaction.
The term 'CMT' is potentially misleading here; the pertinent point simply
being that the transactions are being managed by something other than the
Hibernate transaction mechanism.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final JDBCContextprotected final TransactionFactory.Context -
Constructor Summary
ConstructorsConstructorDescriptionCMTTransaction(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.Getter for property 'transaction'.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?
-
Field Details
-
jdbcContext
-
transactionContext
-
-
Constructor Details
-
CMTTransaction
-
-
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
-
getTransaction
Getter for property 'transaction'.- Returns:
- Value for property 'transaction'.
- Throws:
SystemException
-
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
-
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
-
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.
-