public class

JTATransaction

extends Object
implements Transaction
java.lang.Object
   ↳ org.hibernate.transaction.JTATransaction

Class Overview

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.

Summary

Public Constructors
JTATransaction(UserTransaction userTransaction, JDBCContext jdbcContext, TransactionFactory.Context transactionContext)
Public Methods
void begin()
Begin a new transaction.
void commit()
Flush the associated Session and end the unit of work (unless we are in MANUAL.
boolean isActive()
Is this transaction still active?

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

void registerSynchronization(Synchronization sync)
Register a user synchronization callback for this transaction.
void rollback()
Force the underlying transaction to roll back.
void setTimeout(int seconds)
Set the transaction timeout for any transaction started by a subsequent call to begin() on this instance.
boolean wasCommitted()
Check if this transaction was successfully committed.
boolean wasRolledBack()
Was this transaction rolled back or set to rollback only?

This only accounts for actions initiated from this local transaction.

Protected Methods
UserTransaction getUserTransaction()
Getter for property 'userTransaction'.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.hibernate.Transaction

Public Constructors

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

Public Methods

public void begin ()

Begin a new transaction.

public void commit ()

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

This method will commit the underlying transaction if and only if the underlying transaction was initiated by this object.

public boolean isActive ()

Is this transaction still active?

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

Returns
  • boolean Treu if this local transaction is still active.

public void registerSynchronization (Synchronization sync)

Register a user synchronization callback for this transaction.

Parameters
sync The Synchronization callback to register.

public void rollback ()

Force the underlying transaction to roll back.

public void setTimeout (int seconds)

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

Parameters
seconds The number of seconds before a timeout.

public boolean 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 True if the transaction was (unequivocally) committed via this local transaction; false otherwise.

public boolean 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 True if the transaction was rolled back via this local transaction; false otherwise.

Protected Methods

protected UserTransaction getUserTransaction ()

Getter for property 'userTransaction'.

Returns
  • Value for property 'userTransaction'.