com.atlassian.jira.transaction
Interface Transaction


public interface Transaction

This represents the state of a running transaction that can be comitted or rolled back

Since:
v4.4.1

Method Summary
 void commit()
          This will commit the transaction.
 void finallyRollbackIfNotCommitted()
          This is designed to be called in a top level finally block and it will attempt to rollback the transaction IF it has not already been committed.
 boolean isNewTransaction()
           
 void rollback()
          This will rollback the transaction.
 

Method Detail

commit

void commit()
            throws TransactionRuntimeException
This will commit the transaction.

Throws:
org.ofbiz.core.entity.GenericTransactionException - if the transaction cannot be commited
TransactionRuntimeException

rollback

void rollback()
              throws TransactionRuntimeException
This will rollback the transaction.

Throws:
org.ofbiz.core.entity.GenericTransactionException - if the transaction cannot be rollbacked
TransactionRuntimeException

finallyRollbackIfNotCommitted

void finallyRollbackIfNotCommitted()
This is designed to be called in a top level finally block and it will attempt to rollback the transaction IF it has not already been committed. This allows you to simplify your try/catch/finally blocks in and around transaction code.

Note it DOES NOT throw a {@link TransactionRuntimeException) if the roll back cannot be performed. Since this is intended to be inside a finally block it most likely to late to know about this you probably dont want to do anything since rollback hasnt worked either. So it logs this condition is an ignores it to make calling code more simple.


isNewTransaction

boolean isNewTransaction()
Returns:
if this represents a new transaction and hence whether calling commit() or rollback() will actually do anything


Copyright © 2002-2013 Atlassian. All Rights Reserved.