| org.hibernate.Transaction
All known Subclasses: org.hibernate.transaction.JDBCTransaction, org.hibernate.transaction.CMTTransaction, org.hibernate.transaction.JTATransaction,
Transaction | public interface Transaction (Code) | | Allows the application to define units of work, while
maintaining abstraction from the underlying transaction
implementation (eg. JTA, JDBC).
A transaction is associated with a Session and is
usually instantiated by a call to Session.beginTransaction().
A single session might span multiple transactions since
the notion of a session (a conversation between the application
and the datastore) is of coarser granularity than the notion of
a transaction. However, it is intended that there be at most one
uncommitted Transaction associated with a particular
Session at any time.
Implementors are not intended to be threadsafe.
See Also: Session.beginTransaction See Also: org.hibernate.transaction.TransactionFactory author: Anton van Straaten |
Method Summary | |
public void | begin() Begin a new transaction. | public void | commit() Flush the associated Session and end the unit of work (unless
we are in
FlushMode.NEVER . | public boolean | isActive() Is this transaction still active?
Again, this only returns information in relation to the
local transaction, not the actual underlying transaction. | public void | registerSynchronization(Synchronization synchronization) Register a user synchronization callback for this transaction. | public void | rollback() Force the underlying transaction to roll back. | public void | setTimeout(int seconds) Set the transaction timeout for any transaction started by
a subsequent call to begin() on this instance. | public boolean | wasCommitted() Check if this transaction was successfully committed.
This method could return false even after successful invocation
of
Transaction.commit . | public boolean | wasRolledBack() Was this transaction rolled back or set to rollback only?
This only accounts for actions initiated from this local transaction. |
commit | public void commit() throws HibernateException(Code) | | Flush the associated Session and end the unit of work (unless
we are in
FlushMode.NEVER .
This method will commit the underlying transaction if and only
if the underlying transaction was initiated by this object.
throws: HibernateException - |
isActive | public boolean isActive() throws HibernateException(Code) | | Is this transaction still active?
Again, this only returns information in relation to the
local transaction, not the actual underlying transaction.
boolean Treu if this local transaction is still active. |
registerSynchronization | public void registerSynchronization(Synchronization synchronization) throws HibernateException(Code) | | Register a user synchronization callback for this transaction.
Parameters: synchronization - The Synchronization callback to register. throws: HibernateException - |
setTimeout | public void setTimeout(int seconds)(Code) | | Set the transaction timeout for any transaction started by
a subsequent call to begin() on this instance.
Parameters: seconds - The number of seconds before a timeout. |
wasCommitted | public boolean wasCommitted() throws HibernateException(Code) | | Check if this transaction was successfully committed.
This method could return false even after successful invocation
of
Transaction.commit . As an example, JTA based strategies no-op on
Transaction.commit calls if they did not start the transaction; in that case,
they also report
Transaction.wasCommitted as false.
boolean True if the transaction was (unequivocally) committedvia this local transaction; false otherwise. throws: HibernateException - |
wasRolledBack | public boolean wasRolledBack() throws HibernateException(Code) | | 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.
boolean True if the transaction was rolled back via thislocal transaction; false otherwise. throws: HibernateException - |
|
|