Top Description Fields Constructors Methods
org.hibernate.transaction

public Class JDBCTransaction

extends Object
implements Transaction
Class Inheritance
All Implemented Interfaces
org.hibernate.Transaction
Imports
java.sql.SQLException, javax.transaction.Status, .Synchronization, org.slf4j.Logger, .LoggerFactory, org.hibernate.HibernateException, .Transaction, .TransactionException, org.hibernate.engine.transaction.SynchronizationRegistry, org.hibernate.jdbc.JDBCContext

Transaction implementation based on transaction management through a JDBC java.sql.Connection.

This the Hibernate's default transaction strategy.

Authors
Anton van Straaten, Gavin King

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private boolean
private boolean
private final JDBCContext
private static final Logger
private boolean
private final SynchronizationRegistry
private int
private boolean
private final TransactionFactory.Context

Constructor Summary

AccessConstructor and Description
public
JDBCTransaction(JDBCContext jdbcContext, TransactionFactory.Context transactionContext)

Method Summary

Modifier and TypeMethod and Description
public void
begin()

Implements org.hibernate.Transaction.begin.

Begin a new transaction.
private void
public void
commit()

Implements org.hibernate.Transaction.commit.

Flush the associated Session and end the unit of work (unless we are in FlushMode#MANUAL.
private void
public boolean
isActive()

Implements org.hibernate.Transaction.isActive.

Is this transaction still active?
private void
private void
public void
registerSynchronization(Synchronization
The Synchronization callback to register.
sync
)

Implements org.hibernate.Transaction.registerSynchronization.

Register a user synchronization callback for this transaction.
public void
rollback()

Implements org.hibernate.Transaction.rollback.

Force the underlying transaction to roll back.
private void
public void
setTimeout(int
The number of seconds before a timeout.
seconds
)

Implements org.hibernate.Transaction.setTimeout.

Set the transaction timeout for any transaction started by a subsequent call to begin() on this instance.
private void
public boolean
wasCommitted()

Implements org.hibernate.Transaction.wasCommitted.

Check if this transaction was successfully committed.
public boolean
wasRolledBack()

Implements org.hibernate.Transaction.wasRolledBack.

Was this transaction rolled back or set to rollback only?
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

begunback to summary
private boolean begun
callbackback to summary
private boolean callback
commitFailedback to summary
private boolean commitFailed
committedback to summary
private boolean committed
jdbcContextback to summary
private final JDBCContext jdbcContext
logback to summary
private static final Logger log
rolledBackback to summary
private boolean rolledBack
synchronizationRegistryback to summary
private final SynchronizationRegistry synchronizationRegistry
timeoutback to summary
private int timeout
toggleAutoCommitback to summary
private boolean toggleAutoCommit
transactionContextback to summary
private final TransactionFactory.Context transactionContext

Constructor Detail

JDBCTransactionback to summary
public JDBCTransaction(JDBCContext jdbcContext, TransactionFactory.Context transactionContext)

Method Detail

beginback to summary
public void begin() throws HibernateException

Implements org.hibernate.Transaction.begin.

Doc from org.hibernate.Transaction.begin.

Begin a new transaction.

closeIfRequiredback to summary
private void closeIfRequired() throws HibernateException
commitback to summary
public void commit() throws HibernateException

Implements org.hibernate.Transaction.commit.

Doc from org.hibernate.Transaction.commit.

Flush the associated Session and end the unit of work (unless we are in FlushMode#MANUAL.

This method will commit the underlying transaction if and only if the underlying transaction was initiated by this object.
commitAndResetAutoCommitback to summary
private void commitAndResetAutoCommit() throws SQLException
isActiveback to summary
public boolean isActive()

Implements org.hibernate.Transaction.isActive.

Doc from org.hibernate.Transaction.isActive.

Is this transaction still active?

Again, this only returns information in relation to the local transaction, not the actual underlying transaction.

Returns:boolean

boolean Treu if this local transaction is still active.

notifySynchronizationsAfterTransactionCompletionback to summary
private void notifySynchronizationsAfterTransactionCompletion(int status)
notifySynchronizationsBeforeTransactionCompletionback to summary
private void notifySynchronizationsBeforeTransactionCompletion()
registerSynchronizationback to summary
public void registerSynchronization(Synchronization sync)

Implements org.hibernate.Transaction.registerSynchronization.

Doc from org.hibernate.Transaction.registerSynchronization.

Register a user synchronization callback for this transaction.

Parameters
sync:Synchronization

The Synchronization callback to register.

rollbackback to summary
public void rollback() throws HibernateException

Implements org.hibernate.Transaction.rollback.

Doc from org.hibernate.Transaction.rollback.

Force the underlying transaction to roll back.

rollbackAndResetAutoCommitback to summary
private void rollbackAndResetAutoCommit() throws SQLException
setTimeoutback to summary
public void setTimeout(int seconds)

Implements org.hibernate.Transaction.setTimeout.

Doc from org.hibernate.Transaction.setTimeout.

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.

toggleAutoCommitback to summary
private void toggleAutoCommit()
wasCommittedback to summary
public boolean wasCommitted()

Implements org.hibernate.Transaction.wasCommitted.

Doc from org.hibernate.Transaction.wasCommitted.

Check if this transaction was successfully committed.

This method could return false even after successful invocation of commit. As an example, JTA based strategies no-op on commit calls if they did not start the transaction; in that case, they also report wasCommitted as false.

Returns:boolean

boolean True if the transaction was (unequivocally) committed via this local transaction; false otherwise.

wasRolledBackback to summary
public boolean wasRolledBack()

Implements org.hibernate.Transaction.wasRolledBack.

Doc from org.hibernate.Transaction.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.

Returns:boolean

boolean True if the transaction was rolled back via this local transaction; false otherwise.