Top Description Fields Constructors Methods
org.hibernate.transaction

public Class JTATransaction

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

Transaction implementation based on transaction management through a JTA UserTransaction. Similar to CMTTransaction, except here we are actually managing the transactions through the Hibernate transaction mechanism.
Authors
Gavin King, Steve Ebersole, Les Hazlewood

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 static final int
private final TransactionFactory.Context
private UserTransaction

Constructor Summary

AccessConstructor and Description
public
JTATransaction(UserTransaction userTransaction, JDBCContext jdbcContext, TransactionFactory.Context transactionContext)

Method Summary

Modifier and TypeMethod and Description
private void
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 TransactionManager

Returns:

Value for property 'transactionManager'.
getTransactionManager
()

Getter for property 'transactionManager'.

protected UserTransaction

Returns:

Value for property 'userTransaction'.
getUserTransaction
()

Getter for property 'userTransaction'.

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
callbackback to summary
private boolean callback
commitFailedback to summary
private boolean commitFailed
commitSucceededback to summary
private boolean commitSucceeded
jdbcContextback to summary
private final JDBCContext jdbcContext
logback to summary
private static final Logger log
newTransactionback to summary
private boolean newTransaction
NULLback to summary
private static final int NULL
transactionContextback to summary
private final TransactionFactory.Context transactionContext
userTransactionback to summary
private UserTransaction userTransaction

Constructor Detail

JTATransactionback to summary
public JTATransaction(UserTransaction userTransaction, JDBCContext jdbcContext, TransactionFactory.Context transactionContext)

Method Detail

afterCommitRollbackback to summary
private void afterCommitRollback() throws TransactionException
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.
getTransactionManagerback to summary
private TransactionManager getTransactionManager()

Getter for property 'transactionManager'.

Returns:TransactionManager

Value for property 'transactionManager'.

getUserTransactionback to summary
protected UserTransaction getUserTransaction()

Getter for property 'userTransaction'.

Returns:UserTransaction

Value for property 'userTransaction'.

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.