Class DefaultTransactionStatus
java.lang.Object
org.springframework.transaction.support.AbstractTransactionStatus
org.springframework.transaction.support.DefaultTransactionStatus
- All Implemented Interfaces:
- Flushable,- SavepointManager,- TransactionExecution,- TransactionStatus
Default implementation of the 
TransactionStatus
 interface, used by AbstractPlatformTransactionManager. Based on the concept
 of an underlying "transaction object".
 Holds all status information that AbstractPlatformTransactionManager
 needs internally, including a generic transaction object determined by the
 concrete transaction manager implementation.
 
Supports delegating savepoint-related methods to a transaction object
 that implements the SavepointManager interface.
 
NOTE: This is not intended for use with other PlatformTransactionManager
 implementations, in particular not for mock transaction managers in testing environments.
 Use the alternative SimpleTransactionStatus class or a mock for the plain
 TransactionStatus interface instead.
- Since:
- 19.01.2004
- Author:
- Juergen Hoeller
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionDefaultTransactionStatus(Object transaction, boolean newTransaction, boolean newSynchronization, boolean readOnly, boolean debug, Object suspendedResources) Create a newDefaultTransactionStatusinstance.
- 
Method SummaryModifier and TypeMethodDescriptionvoidflush()Delegate the flushing to the transaction object, provided that the latter implements theSmartTransactionObjectinterface.protected SavepointManagerThis implementation exposes theSavepointManagerinterface of the underlying transaction object, if any.Return the holder for resources that have been suspended for this transaction, if any.Return the underlying transaction object.booleanReturn whether there is an actual transaction active.booleanisDebug()Return whether the progress of this transaction is debugged.booleanDetermine the rollback-only flag via checking the transaction object, provided that the latter implements theSmartTransactionObjectinterface.booleanReturn if a new transaction synchronization has been opened for this transaction.booleanReturn whether the present transaction is new; otherwise participating in an existing transaction, or potentially not running in an actual transaction in the first place.booleanReturn if this transaction is defined as read-only transaction.booleanReturn whether the underlying transaction implements theSavepointManagerinterface and therefore supports savepoints.Methods inherited from class org.springframework.transaction.support.AbstractTransactionStatuscreateAndHoldSavepoint, createSavepoint, getSavepoint, hasSavepoint, isCompleted, isLocalRollbackOnly, isRollbackOnly, releaseHeldSavepoint, releaseSavepoint, rollbackToHeldSavepoint, rollbackToSavepoint, setCompleted, setRollbackOnly, setSavepoint
- 
Constructor Details- 
DefaultTransactionStatuspublic DefaultTransactionStatus(@Nullable Object transaction, boolean newTransaction, boolean newSynchronization, boolean readOnly, boolean debug, @Nullable Object suspendedResources) Create a newDefaultTransactionStatusinstance.- Parameters:
- transaction- underlying transaction object that can hold state for the internal transaction implementation
- newTransaction- if the transaction is new, otherwise participating in an existing transaction
- newSynchronization- if a new transaction synchronization has been opened for the given transaction
- readOnly- whether the transaction is marked as read-only
- debug- should debug logging be enabled for the handling of this transaction? Caching it in here can prevent repeated calls to ask the logging system whether debug logging should be enabled.
- suspendedResources- a holder for resources that have been suspended for this transaction, if any
 
 
- 
- 
Method Details- 
getTransactionReturn the underlying transaction object.- Throws:
- IllegalStateException- if no transaction is active
 
- 
hasTransactionpublic boolean hasTransaction()Return whether there is an actual transaction active.
- 
isNewTransactionpublic boolean isNewTransaction()Description copied from interface:TransactionExecutionReturn whether the present transaction is new; otherwise participating in an existing transaction, or potentially not running in an actual transaction in the first place.
- 
isNewSynchronizationpublic boolean isNewSynchronization()Return if a new transaction synchronization has been opened for this transaction.
- 
isReadOnlypublic boolean isReadOnly()Return if this transaction is defined as read-only transaction.
- 
isDebugpublic boolean isDebug()Return whether the progress of this transaction is debugged. This is used byAbstractPlatformTransactionManageras an optimization, to prevent repeated calls tologger.isDebugEnabled(). Not really intended for client code.
- 
getSuspendedResourcesReturn the holder for resources that have been suspended for this transaction, if any.
- 
isGlobalRollbackOnlypublic boolean isGlobalRollbackOnly()Determine the rollback-only flag via checking the transaction object, provided that the latter implements theSmartTransactionObjectinterface.Will return trueif the global transaction itself has been marked rollback-only by the transaction coordinator, for example in case of a timeout.- Overrides:
- isGlobalRollbackOnlyin class- AbstractTransactionStatus
- See Also:
 
- 
getSavepointManagerThis implementation exposes theSavepointManagerinterface of the underlying transaction object, if any.- Overrides:
- getSavepointManagerin class- AbstractTransactionStatus
- Throws:
- NestedTransactionNotSupportedException- if savepoints are not supported
- See Also:
 
- 
isTransactionSavepointManagerpublic boolean isTransactionSavepointManager()Return whether the underlying transaction implements theSavepointManagerinterface and therefore supports savepoints.- See Also:
 
- 
flushpublic void flush()Delegate the flushing to the transaction object, provided that the latter implements theSmartTransactionObjectinterface.- Specified by:
- flushin interface- Flushable
- Specified by:
- flushin interface- TransactionStatus
- Overrides:
- flushin class- AbstractTransactionStatus
- See Also:
 
 
-