Top Description Fields Constructors Methods
org.hibernate.transaction

public Class CMTTransaction

extends Object
implements Transaction
Class Inheritance
All Implemented Interfaces
org.hibernate.Transaction
Imports
javax.transaction.Status, .Synchronization, .SystemException, org.slf4j.Logger, .LoggerFactory, org.hibernate.HibernateException, .Transaction, .TransactionException, org.hibernate.jdbc.JDBCContext, org.hibernate.util.JTAHelper

Implements a basic transaction strategy for CMT transactions. All work is done in the context of the container managed transaction.

The term 'CMT' is potentially misleading here; the pertinent point simply being that the transactions are being managed by something other than the Hibernate transaction mechanism.

Author
Gavin King

Field Summary

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

Constructor Summary

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

Method Summary

Modifier and TypeMethod and Description
public void
begin()

Implements org.hibernate.Transaction.begin.

Begin a new transaction.
public void
commit()

Implements org.hibernate.Transaction.commit.

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

Returns:

Value for property 'transaction'.
getTransaction
()

Getter for property 'transaction'.

public boolean
isActive()

Implements org.hibernate.Transaction.isActive.

Is this transaction still active?
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.
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.
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
jdbcContextback to summary
protected final JDBCContext jdbcContext
logback to summary
private static final Logger log
transactionContextback to summary
protected final TransactionFactory.Context transactionContext

Constructor Detail

CMTTransactionback to summary
public CMTTransaction(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.

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.
getTransactionback to summary
public Transaction getTransaction() throws SystemException

Getter for property 'transaction'.

Returns:Transaction

Value for property 'transaction'.

isActiveback to summary
public boolean isActive() throws TransactionException

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.

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

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.

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.

wasCommittedback to summary
public boolean wasCommitted() throws TransactionException

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() throws TransactionException

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.