Top Description Methods
org.hibernate

public Interface Transaction

extends EntityTransaction
Known Direct Subinterfaces
org.hibernate.engine.transaction.spi.TransactionImplementor
Imports
javax.persistence.EntityTransaction, javax.transaction.Synchronization, org.hibernate.resource.transaction.spi.TransactionStatus

Defines the contract for abstracting applications from the configured underlying means of transaction management. 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 initiated by a call to org.hibernate.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.

Implementers are not intended to be thread-safe.

Authors
Anton van Straaten, Steve Ebersole

Method Summary

Modifier and TypeMethod and Description
public TransactionStatus

Returns:

The current local status.
getStatus
()

Get the current local status of this transaction.

public int

Returns:

The timeout, in seconds.
getTimeout
()

Retrieve the transaction timeout set for this transaction.

public default void
markRollbackOnly()

Make a best effort to mark the underlying transaction for rollback only.

public void
registerSynchronization(Synchronization
The Synchronization callback to register.
synchronization
)

Register a user synchronization callback for this transaction.

public void
setTimeout(int
The number of seconds before a timeout.
seconds
)

Set the transaction timeout for any transaction started by a subsequent call to begin on this instance.

Inherited from javax.persistence.EntityTransaction:
begincommitgetRollbackOnlyisActiverollbacksetRollbackOnly

Method Detail

getStatusback to summary
public TransactionStatus getStatus()

Get the current local status of this transaction.

This only accounts for the local view of the transaction status. In other words it does not check the status of the actual underlying transaction.

Returns:TransactionStatus

The current local status.

getTimeoutback to summary
public int getTimeout()

Retrieve the transaction timeout set for this transaction. A negative indicates no timeout has been set.

Returns:int

The timeout, in seconds.

markRollbackOnlyback to summary
public default void markRollbackOnly()

Make a best effort to mark the underlying transaction for rollback only.

registerSynchronizationback to summary
public void registerSynchronization(Synchronization synchronization) throws HibernateException

Register a user synchronization callback for this transaction.

Parameters
synchronization:Synchronization

The Synchronization callback to register.

Exceptions
HibernateException:
Indicates a problem registering the synchronization.
setTimeoutback to summary
public void setTimeout(int seconds)

Set the transaction timeout for any transaction started by a subsequent call to begin on this instance.

Parameters
seconds:int

The number of seconds before a timeout.