Class AbstractTransactionStatus
- All Implemented Interfaces:
- Flushable,- SavepointManager,- TransactionExecution,- TransactionStatus
- Direct Known Subclasses:
- DefaultTransactionStatus,- SimpleTransactionStatus
TransactionStatus interface.
 Pre-implements the handling of local rollback-only and completed flags, and
 delegation to an underlying SavepointManager.
 Also offers the option of a holding a savepoint within the transaction.
 
Does not assume any specific internal transaction handling, such as an underlying transaction object, and no transaction synchronization mechanism.
- Since:
- 1.2.3
- Author:
- Juergen Hoeller
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidCreate a savepoint and hold it for the transaction.This implementation delegates to a SavepointManager for the underlying transaction, if possible.voidflush()This implementation is empty, considering flush as a no-op.protected ObjectGet the savepoint for this transaction, if any.protected SavepointManagerReturn a SavepointManager for the underlying transaction, if possible.booleanReturn whether this transaction internally carries a savepoint, that is, has been created as nested transaction based on a savepoint.booleanReturn whether this transaction is completed, that is, whether it has already been committed or rolled back.booleanTemplate method for determining the global rollback-only flag of the underlying transaction, if any.booleanDetermine the rollback-only flag via checking this TransactionStatus.booleanDetermine the rollback-only flag via checking both the local rollback-only flag of this TransactionStatus and the global rollback-only flag of the underlying transaction, if any.voidRelease the savepoint that is held for the transaction.voidreleaseSavepoint(Object savepoint) This implementation delegates to a SavepointManager for the underlying transaction, if possible.voidRoll back to the savepoint that is held for the transaction and release the savepoint right afterwards.voidrollbackToSavepoint(Object savepoint) This implementation delegates to a SavepointManager for the underlying transaction, if possible.voidMark this transaction as completed, that is, committed or rolled back.voidSet the transaction rollback-only.protected voidsetSavepoint(Object savepoint) Set a savepoint for this transaction.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.transaction.TransactionExecutionisNewTransaction
- 
Constructor Details- 
AbstractTransactionStatuspublic AbstractTransactionStatus()
 
- 
- 
Method Details- 
setRollbackOnlypublic void setRollbackOnly()Description copied from interface:TransactionExecutionSet 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.- Specified by:
- setRollbackOnlyin interface- TransactionExecution
 
- 
isRollbackOnlypublic boolean isRollbackOnly()Determine the rollback-only flag via checking both the local rollback-only flag of this TransactionStatus and the global rollback-only flag of the underlying transaction, if any.- Specified by:
- isRollbackOnlyin interface- TransactionExecution
- See Also:
 
- 
isLocalRollbackOnlypublic boolean isLocalRollbackOnly()Determine the rollback-only flag via checking this TransactionStatus.Will only return "true" if the application called setRollbackOnlyon this TransactionStatus object.
- 
isGlobalRollbackOnlypublic boolean isGlobalRollbackOnly()Template method for determining the global rollback-only flag of the underlying transaction, if any.This implementation always returns false.
- 
setCompletedpublic void setCompleted()Mark this transaction as completed, that is, committed or rolled back.
- 
isCompletedpublic boolean isCompleted()Description copied from interface:TransactionExecutionReturn whether this transaction is completed, that is, whether it has already been committed or rolled back.- Specified by:
- isCompletedin interface- TransactionExecution
 
- 
hasSavepointpublic boolean hasSavepoint()Description copied from interface:TransactionStatusReturn 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 TransactionExecution.isNewTransaction(). For programmatic handling of custom savepoints, use the operations provided bySavepointManager.
- 
setSavepointSet a savepoint for this transaction. Useful for PROPAGATION_NESTED.- See Also:
 
- 
getSavepointGet the savepoint for this transaction, if any.
- 
createAndHoldSavepointCreate a savepoint and hold it for the transaction.- Throws:
- NestedTransactionNotSupportedException- if the underlying transaction does not support savepoints
- TransactionException
 
- 
rollbackToHeldSavepointRoll back to the savepoint that is held for the transaction and release the savepoint right afterwards.- Throws:
- TransactionException
 
- 
releaseHeldSavepointRelease the savepoint that is held for the transaction.- Throws:
- TransactionException
 
- 
createSavepointThis implementation delegates to a SavepointManager for the underlying transaction, if possible.- Specified by:
- createSavepointin interface- SavepointManager
- Returns:
- a savepoint object, to be passed into
 SavepointManager.rollbackToSavepoint(java.lang.Object)orSavepointManager.releaseSavepoint(java.lang.Object)
- Throws:
- NestedTransactionNotSupportedException- if the underlying transaction does not support savepoints
- TransactionException- if the savepoint could not be created, for example because the transaction is not in an appropriate state
- See Also:
 
- 
rollbackToSavepointThis implementation delegates to a SavepointManager for the underlying transaction, if possible.- Specified by:
- rollbackToSavepointin interface- SavepointManager
- Parameters:
- savepoint- the savepoint to roll back to
- Throws:
- NestedTransactionNotSupportedException- if the underlying transaction does not support savepoints
- TransactionException- if the rollback failed
- See Also:
 
- 
releaseSavepointThis implementation delegates to a SavepointManager for the underlying transaction, if possible.- Specified by:
- releaseSavepointin interface- SavepointManager
- Parameters:
- savepoint- the savepoint to release
- Throws:
- NestedTransactionNotSupportedException- if the underlying transaction does not support savepoints
- TransactionException- if the release failed
- See Also:
 
- 
getSavepointManagerReturn a SavepointManager for the underlying transaction, if possible.Default implementation always throws a NestedTransactionNotSupportedException. - Throws:
- NestedTransactionNotSupportedException- if the underlying transaction does not support savepoints
 
- 
flushpublic void flush()This implementation is empty, considering flush as a no-op.- Specified by:
- flushin interface- Flushable
- Specified by:
- flushin interface- TransactionStatus
 
 
-