Package org.hibernate

Interface Transaction

All Superinterfaces:
EntityTransaction
All Known Subinterfaces:
TransactionImplementor
All Known Implementing Classes:
TransactionImpl

public interfaceTransactionextendsEntityTransaction
Represents a resource-local transaction, whereresource-local is interpreted by Hibernate to mean any transaction under the control of Hibernate. That is to say, the underlying transaction might be a JTA transaction, or it might be a JDBC transaction, depending on how Hibernate is configured.

Every resource-local transaction is associated with aSession and begins with an explicit call toSharedSessionContract.beginTransaction(), or, almost equivalently, withsession.getTransaction().begin(), and ends with a call toEntityTransaction.commit() orEntityTransaction.rollback().

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 concept of a database transaction. However, there is at most one uncommitted transaction associated with a givenSession at any time.

Note that this interface is never used to control container managed JTA transactions, and is not usually used to control transactions that affect multiple resources.

ATransaction object is not threadsafe.

See Also:
API Note:
JPA doesn't allow anEntityTransaction to represent a JTA transaction. But whenstrict JPA transaction compliance is disabled, as it is by default, Hibernate allows an instance of this interface to represent the current JTA transaction context.