Package org.hibernate.transaction
Class JDBCTransaction
java.lang.Object
org.hibernate.transaction.JDBCTransaction
- All Implemented Interfaces:
Transaction
Transaction implementation based on transaction management through a JDBC Connection.
This the Hibernate's default transaction strategy.-
Constructor Summary
ConstructorsConstructorDescriptionJDBCTransaction(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.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
-
JDBCTransaction
-
-
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
public boolean 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.
-
wasCommitted
public boolean 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.
-
isActive
public boolean 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.
-
registerSynchronization
Register a user synchronization callback for this transaction.- Specified by:
registerSynchronizationin interfaceTransaction- Parameters:
sync- The Synchronization callback to register.
-
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.
-