类 DefaultTransactionStatus
- java.lang.Object
- org.springframework.transaction.support.AbstractTransactionStatus
- org.springframework.transaction.support.DefaultTransactionStatus
public class DefaultTransactionStatus extends AbstractTransactionStatus
Default implementation of theTransactionStatusinterface, used byAbstractPlatformTransactionManager. Based on the concept of an underlying "transaction object".Holds all status information that
AbstractPlatformTransactionManagerneeds 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
SavepointManagerinterface.NOTE: This is not intended for use with other PlatformTransactionManager implementations, in particular not for mock transaction managers in testing environments. Use the alternative
SimpleTransactionStatusclass or a mock for the plainTransactionStatusinterface instead.- 从以下版本开始:
- 19.01.2004
- 作者:
- Juergen Hoeller
- 另请参阅:
AbstractPlatformTransactionManager,SavepointManager,getTransaction(),AbstractTransactionStatus.createSavepoint(),AbstractTransactionStatus.rollbackToSavepoint(java.lang.Object),AbstractTransactionStatus.releaseSavepoint(java.lang.Object),SimpleTransactionStatus
构造器概要
构造器 构造器 说明 DefaultTransactionStatus(Object transaction, boolean newTransaction, boolean newSynchronization, boolean readOnly, boolean debug, Object suspendedResources)Create a newDefaultTransactionStatusinstance.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidflush()Delegate the flushing to the transaction object, provided that the latter implements theSmartTransactionObjectinterface.protected SavepointManagergetSavepointManager()This implementation exposes theSavepointManagerinterface of the underlying transaction object, if any.ObjectgetSuspendedResources()Return the holder for resources that have been suspended for this transaction, if any.ObjectgetTransaction()Return the underlying transaction object.booleanhasTransaction()Return whether there is an actual transaction active.booleanisDebug()Return whether the progress of this transaction is debugged.booleanisGlobalRollbackOnly()Determine the rollback-only flag via checking the transaction object, provided that the latter implements theSmartTransactionObjectinterface.booleanisNewSynchronization()Return if a new transaction synchronization has been opened for this transaction.booleanisNewTransaction()Return whether the present transaction is new; otherwise participating in an existing transaction, or potentially not running in an actual transaction in the first place.booleanisReadOnly()Return if this transaction is defined as read-only transaction.booleanisTransactionSavepointManager()Return whether the underlying transaction implements theSavepointManagerinterface and therefore supports savepoints.从类继承的方法 org.springframework.transaction.support.AbstractTransactionStatus
createAndHoldSavepoint, createSavepoint, getSavepoint, hasSavepoint, isCompleted, isLocalRollbackOnly, isRollbackOnly, releaseHeldSavepoint, releaseSavepoint, rollbackToHeldSavepoint, rollbackToSavepoint, setCompleted, setRollbackOnly, setSavepoint
构造器详细资料
DefaultTransactionStatus
public DefaultTransactionStatus(@Nullable Object transaction, boolean newTransaction, boolean newSynchronization, boolean readOnly, boolean debug, @Nullable Object suspendedResources)
Create a newDefaultTransactionStatusinstance.- 参数:
transaction- underlying transaction object that can hold state for the internal transaction implementationnewTransaction- if the transaction is new, otherwise participating in an existing transactionnewSynchronization- if a new transaction synchronization has been opened for the given transactionreadOnly- whether the transaction is marked as read-onlydebug- 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
方法详细资料
getTransaction
public Object getTransaction()
Return the underlying transaction object.- 抛出:
IllegalStateException- if no transaction is active
hasTransaction
public boolean hasTransaction()
Return whether there is an actual transaction active.
isNewTransaction
public boolean isNewTransaction()
从接口复制的说明: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.
isNewSynchronization
public boolean isNewSynchronization()
Return if a new transaction synchronization has been opened for this transaction.
isReadOnly
public boolean isReadOnly()
Return if this transaction is defined as read-only transaction.
isDebug
public 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.
getSuspendedResources
@Nullable public Object getSuspendedResources()
Return the holder for resources that have been suspended for this transaction, if any.
isGlobalRollbackOnly
public 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.
getSavepointManager
protected SavepointManager getSavepointManager()
This implementation exposes theSavepointManagerinterface of the underlying transaction object, if any.- 覆盖:
getSavepointManager在类中AbstractTransactionStatus- 抛出:
NestedTransactionNotSupportedException- if savepoints are not supported- 另请参阅:
isTransactionSavepointManager()
isTransactionSavepointManager
public boolean isTransactionSavepointManager()
Return whether the underlying transaction implements theSavepointManagerinterface and therefore supports savepoints.
flush
public void flush()
Delegate the flushing to the transaction object, provided that the latter implements theSmartTransactionObjectinterface.- 指定者:
flush在接口中Flushable- 指定者:
flush在接口中TransactionStatus- 覆盖:
flush在类中AbstractTransactionStatus- 另请参阅:
SmartTransactionObject.flush()