org.springframework.transaction
Interface TransactionStatus

All Superinterfaces:
SavepointManager
All Known Implementing Classes:
AbstractTransactionStatus, DefaultTransactionStatus, SimpleTransactionStatus

public interface TransactionStatus
extends SavepointManager

Representation of the status of a transaction.

Transactional code can use this to retrieve status information, and to programmatically request a rollback (instead of throwing an exception that causes an implicit rollback).

Derives from the SavepointManager interface to provide access to savepoint management facilities. Note that savepoint management is only available if supported by the underlying transaction manager.

Since:
27.03.2003
Author:
Juergen Hoeller
See Also:
setRollbackOnly(), PlatformTransactionManager.getTransaction(org.springframework.transaction.TransactionDefinition), TransactionCallback.doInTransaction(org.springframework.transaction.TransactionStatus), TransactionAspectSupport.currentTransactionStatus()

Method Summary
 void flush()
          Flush the underlying session to the datastore, if applicable: for example, all affected Hibernate/JPA sessions.
 boolean hasSavepoint()
          Return whether this transaction internally carries a savepoint, that is, has been created as nested transaction based on a savepoint.
 boolean isCompleted()
          Return whether this transaction is completed, that is, whether it has already been committed or rolled back.
 boolean isNewTransaction()
          Return whether the present transaction is new (else participating in an existing transaction, or potentially not running in an actual transaction in the first place).
 boolean isRollbackOnly()
          Return whether the transaction has been marked as rollback-only (either by the application or by the transaction infrastructure).
 void setRollbackOnly()
          Set the transaction rollback-only.
 
Methods inherited from interface org.springframework.transaction.SavepointManager
createSavepoint, releaseSavepoint, rollbackToSavepoint
 

Method Detail

isNewTransaction

boolean isNewTransaction()
Return whether the present transaction is new (else participating in an existing transaction, or potentially not running in an actual transaction in the first place).


hasSavepoint

boolean hasSavepoint()
Return whether this transaction internally carries a savepoint, that is, has been created as nested transaction based on a savepoint.

This method is mainly here for diagnostic purposes, alongside isNewTransaction(). For programmatic handling of custom savepoints, use SavepointManager's operations.

See Also:
isNewTransaction(), SavepointManager.createSavepoint(), SavepointManager.rollbackToSavepoint(Object), SavepointManager.releaseSavepoint(Object)

setRollbackOnly

void setRollbackOnly()
Set the transaction rollback-only. This instructs the transaction manager that the only possible outcome of the transaction may be a rollback, as alternative to throwing an exception which would in turn trigger a rollback.

This is mainly intended for transactions managed by TransactionTemplate or TransactionInterceptor, where the actual commit/rollback decision is made by the container.

See Also:
TransactionCallback.doInTransaction(org.springframework.transaction.TransactionStatus), TransactionAttribute.rollbackOn(java.lang.Throwable)

isRollbackOnly

boolean isRollbackOnly()
Return whether the transaction has been marked as rollback-only (either by the application or by the transaction infrastructure).


flush

void flush()
Flush the underlying session to the datastore, if applicable: for example, all affected Hibernate/JPA sessions.


isCompleted

boolean isCompleted()
Return whether this transaction is completed, that is, whether it has already been committed or rolled back.

See Also:
PlatformTransactionManager.commit(org.springframework.transaction.TransactionStatus), PlatformTransactionManager.rollback(org.springframework.transaction.TransactionStatus)