public interface Transaction
Session
and is usually initiated by a call to
SharedSessionContract.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.
Implementers are not intended to be thread-safe.Modifier and Type | Method and Description |
---|---|
void |
begin()
Begin this transaction.
|
void |
commit()
Commit this transaction.
|
LocalStatus |
getLocalStatus()
Get the current local status of this transaction.
|
int |
getTimeout()
Retrieve the transaction timeout set for this transaction.
|
boolean |
isActive()
Is this transaction still active?
Answers on a best effort basis.
|
boolean |
isInitiator()
Is this transaction the initiator of any underlying transaction?
|
boolean |
isParticipating()
Is Hibernate participating in the underlying transaction?
Generally speaking this will be the same as
isActive() . |
void |
registerSynchronization(Synchronization synchronization)
Register a user synchronization callback for this transaction.
|
void |
rollback()
Rollback this transaction.
|
void |
setTimeout(int seconds)
Set the transaction timeout for any transaction started by a subsequent call to
begin() on this instance. |
boolean |
wasCommitted()
Was this transaction committed?
Answers on a best effort basis.
|
boolean |
wasRolledBack()
Was this transaction rolled back or set to rollback only?
Answers on a best effort basis.
|
boolean isInitiator()
true
if this transaction initiated the underlying transaction; false
otherwise.void begin()
commit()
or rollback()
will error.HibernateException
- Indicates a problem beginning the transaction.void commit()
initiator
, Session.flush()
the Session
with which it is associated (unless Session
is in FlushMode.MANUAL
).
initiator
, commit the underlying transaction.
HibernateException
- Indicates a problem committing the transaction.void rollback()
HibernateException
- Indicates a problem rolling back the transaction.LocalStatus getLocalStatus()
boolean isActive()
Connection
, only when
it is initiated from here.true
if the transaction is still active; false
otherwise.HibernateException
- Indicates a problem checking the transaction status.boolean isParticipating()
isActive()
.true
if Hibernate is known to be participating in the underlying transaction; false
otherwise.boolean wasCommitted()
Connection
,
only when the commit was done from this.true
if the transaction is rolled back; false
otherwise.HibernateException
- Indicates a problem checking the transaction status.boolean wasRolledBack()
Connection
,
only when it was rolled back from here.HibernateException
- Indicates a problem checking the transaction status.void registerSynchronization(Synchronization synchronization) throws HibernateException
synchronization
- The Synchronization callback to register.HibernateException
- Indicates a problem registering the synchronization.void setTimeout(int seconds)
begin()
on this instance.seconds
- The number of seconds before a timeout.int getTimeout()
Copyright © 2001-2013 Red Hat, Inc. All Rights Reserved.