org.hibernate.engine.transaction.spi
Class AbstractTransactionImpl

java.lang.Object
  extended by org.hibernate.engine.transaction.spi.AbstractTransactionImpl
All Implemented Interfaces:
TransactionImplementor, Transaction
Direct Known Subclasses:
CMTTransaction, JdbcTransaction, JtaTransaction

public abstract class AbstractTransactionImpl
extends Object
implements TransactionImplementor

Abstract support for creating transaction implementations


Constructor Summary
protected AbstractTransactionImpl(TransactionCoordinator transactionCoordinator)
           
 
Method Summary
protected abstract  void afterAfterCompletion()
           
protected abstract  void afterTransactionBegin()
           
protected abstract  void afterTransactionCompletion(int status)
           
protected  boolean allowFailedCommitToPhysicallyRollback()
           
protected abstract  void beforeTransactionCommit()
           
protected abstract  void beforeTransactionRollBack()
           
 void begin()
          Begin this transaction.
 void commit()
          Commit this transaction.
protected abstract  void doBegin()
          Perform the actual steps of beginning a transaction according to the strategy.
protected abstract  void doCommit()
          Perform the actual steps of committing a transaction according to the strategy.
protected  boolean doExtendedActiveCheck()
          Active has been checked against local state.
protected abstract  void doRollback()
          Perform the actual steps of rolling back a transaction according to the strategy.
 LocalStatus getLocalStatus()
          Get the current local status of this transaction.
 int getTimeout()
          Retrieve the transaction timeout set for this transaction.
 void invalidate()
          Called after completion of the underlying transaction to signify the facade is no longer valid.
 boolean isActive()
          Is this transaction still active?

Answers on a best effort basis.

 boolean isParticipating()
          Is Hibernate participating in the underlying transaction?

Generally speaking this will be the same as Transaction.isActive().

 void join()
          Perform a join to the underlying transaction
protected  JtaPlatform jtaPlatform()
          Provide subclasses with convenient access to the configured JtaPlatform
 void markForJoin()
          Mark a transaction as joinable
 void registerSynchronization(Synchronization synchronization)
          Register a user synchronization callback for this transaction.
 void resetJoinStatus()
          Reset this transaction's join status.
 void rollback()
          Rollback this transaction.
 void setTimeout(int seconds)
          Set the transaction timeout for any transaction started by a subsequent call to Transaction.begin() on this instance.
protected  TransactionCoordinator transactionCoordinator()
          Provide subclasses with access to the transaction coordinator.
 boolean wasCommitted()
          Was this transaction committed?

Answers on a best effort basis.

 boolean wasRolledBack()
          Was this transaction rolled back or set to rollback only?

Answers on a best effort basis.

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.hibernate.engine.transaction.spi.TransactionImplementor
createIsolationDelegate, getJoinStatus, markRollbackOnly
 
Methods inherited from interface org.hibernate.Transaction
isInitiator
 

Constructor Detail

AbstractTransactionImpl

protected AbstractTransactionImpl(TransactionCoordinator transactionCoordinator)
Method Detail

invalidate

public void invalidate()
Description copied from interface: TransactionImplementor
Called after completion of the underlying transaction to signify the facade is no longer valid.

Specified by:
invalidate in interface TransactionImplementor

doBegin

protected abstract void doBegin()
Perform the actual steps of beginning a transaction according to the strategy.

Throws:
TransactionException - Indicates a problem beginning the transaction

doCommit

protected abstract void doCommit()
Perform the actual steps of committing a transaction according to the strategy.

Throws:
TransactionException - Indicates a problem committing the transaction

doRollback

protected abstract void doRollback()
Perform the actual steps of rolling back a transaction according to the strategy.

Throws:
TransactionException - Indicates a problem rolling back the transaction

afterTransactionBegin

protected abstract void afterTransactionBegin()

beforeTransactionCommit

protected abstract void beforeTransactionCommit()

beforeTransactionRollBack

protected abstract void beforeTransactionRollBack()

afterTransactionCompletion

protected abstract void afterTransactionCompletion(int status)

afterAfterCompletion

protected abstract void afterAfterCompletion()

transactionCoordinator

protected TransactionCoordinator transactionCoordinator()
Provide subclasses with access to the transaction coordinator.

Returns:
This transaction's context.

jtaPlatform

protected JtaPlatform jtaPlatform()
Provide subclasses with convenient access to the configured JtaPlatform

Returns:
The JtaPlatform

registerSynchronization

public void registerSynchronization(Synchronization synchronization)
Description copied from interface: Transaction
Register a user synchronization callback for this transaction.

Specified by:
registerSynchronization in interface Transaction
Parameters:
synchronization - The Synchronization callback to register.

getLocalStatus

public LocalStatus getLocalStatus()
Description copied from interface: Transaction
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.

Specified by:
getLocalStatus in interface Transaction
Returns:
The current local status.

isActive

public boolean isActive()
Description copied from interface: Transaction
Is this transaction still active?

Answers on a best effort basis. For example, in the case of JDBC based transactions we cannot know that a transaction is active when it is initiated directly through the JDBC Connection, only when it is initiated from here.

Specified by:
isActive in interface Transaction
Returns:
true if the transaction is still active; false otherwise.

isParticipating

public boolean isParticipating()
Description copied from interface: Transaction
Is Hibernate participating in the underlying transaction?

Generally speaking this will be the same as Transaction.isActive().

Specified by:
isParticipating in interface Transaction
Returns:
true if Hibernate is known to be participating in the underlying transaction; false otherwise.

wasCommitted

public boolean wasCommitted()
Description copied from interface: Transaction
Was this transaction committed?

Answers on a best effort basis. For example, in the case of JDBC based transactions we cannot know that a transaction was committed when the commit was performed directly through the JDBC Connection, only when the commit was done from this.

Specified by:
wasCommitted in interface Transaction
Returns:
true if the transaction is rolled back; false otherwise.

wasRolledBack

public boolean wasRolledBack()
                      throws HibernateException
Description copied from interface: Transaction
Was this transaction rolled back or set to rollback only?

Answers on a best effort basis. For example, in the case of JDBC based transactions we cannot know that a transaction was rolled back when rollback was performed directly through the JDBC Connection, only when it was rolled back from here.

Specified by:
wasRolledBack in interface Transaction
Returns:
true if the transaction is rolled back; false otherwise.
Throws:
HibernateException - Indicates a problem checking the transaction status.

doExtendedActiveCheck

protected boolean doExtendedActiveCheck()
Active has been checked against local state. Perform any needed checks against resource transactions.

Returns:
true if the extended active check checks out as well; false otherwise.

begin

public void begin()
           throws HibernateException
Description copied from interface: Transaction
Begin this transaction. No-op if the transaction has already been begun. Note that this is not necessarily symmetrical since usually multiple calls to Transaction.commit() or Transaction.rollback() will error.

Specified by:
begin in interface Transaction
Throws:
HibernateException - Indicates a problem beginning the transaction.

commit

public void commit()
            throws HibernateException
Description copied from interface: Transaction
Commit this transaction. This might entail a number of things depending on the context:

Specified by:
commit in interface Transaction
Throws:
HibernateException - Indicates a problem committing the transaction.

allowFailedCommitToPhysicallyRollback

protected boolean allowFailedCommitToPhysicallyRollback()

rollback

public void rollback()
              throws HibernateException
Description copied from interface: Transaction
Rollback this transaction. Either rolls back the underlying transaction or ensures it cannot later commit (depending on the actual underlying strategy).

Specified by:
rollback in interface Transaction
Throws:
HibernateException - Indicates a problem rolling back the transaction.

setTimeout

public void setTimeout(int seconds)
Description copied from interface: Transaction
Set the transaction timeout for any transaction started by a subsequent call to Transaction.begin() on this instance.

Specified by:
setTimeout in interface Transaction
Parameters:
seconds - The number of seconds before a timeout.

getTimeout

public int getTimeout()
Description copied from interface: Transaction
Retrieve the transaction timeout set for this transaction. A negative indicates no timeout has been set.

Specified by:
getTimeout in interface Transaction
Returns:
The timeout, in seconds.

markForJoin

public void markForJoin()
Description copied from interface: TransactionImplementor
Mark a transaction as joinable

Specified by:
markForJoin in interface TransactionImplementor

join

public void join()
Description copied from interface: TransactionImplementor
Perform a join to the underlying transaction

Specified by:
join in interface TransactionImplementor

resetJoinStatus

public void resetJoinStatus()
Description copied from interface: TransactionImplementor
Reset this transaction's join status.

Specified by:
resetJoinStatus in interface TransactionImplementor


Copyright © 2001-2015 Red Hat, Inc. All Rights Reserved.