类 AbstractTransactionStatus
- java.lang.Object
- org.springframework.transaction.support.AbstractTransactionStatus
- 所有已实现的接口:
Flushable,SavepointManager,TransactionStatus
public abstract class AbstractTransactionStatus extends Object implements TransactionStatus
Abstract base implementation of theTransactionStatusinterface.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.
- 从以下版本开始:
- 1.2.3
- 作者:
- Juergen Hoeller
- 另请参阅:
setRollbackOnly(),isRollbackOnly(),setCompleted(),isCompleted(),getSavepointManager(),SimpleTransactionStatus,DefaultTransactionStatus
构造器概要
构造器 构造器 说明 AbstractTransactionStatus()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidcreateAndHoldSavepoint()Create a savepoint and hold it for the transaction.ObjectcreateSavepoint()This implementation delegates to a SavepointManager for the underlying transaction, if possible.voidflush()This implementations is empty, considering flush as a no-op.protected ObjectgetSavepoint()Get the savepoint for this transaction, if any.protected SavepointManagergetSavepointManager()Return a SavepointManager for the underlying transaction, if possible.booleanhasSavepoint()Return whether this transaction internally carries a savepoint, that is, has been created as nested transaction based on a savepoint.booleanisCompleted()Return whether this transaction is completed, that is, whether it has already been committed or rolled back.booleanisGlobalRollbackOnly()Template method for determining the global rollback-only flag of the underlying transaction, if any.booleanisLocalRollbackOnly()Determine the rollback-only flag via checking this TransactionStatus.booleanisRollbackOnly()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.voidreleaseHeldSavepoint()Release the savepoint that is held for the transaction.voidreleaseSavepoint(Object savepoint)This implementation delegates to a SavepointManager for the underlying transaction, if possible.voidrollbackToHeldSavepoint()Roll 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.voidsetCompleted()Mark this transaction as completed, that is, committed or rolled back.voidsetRollbackOnly()Set the transaction rollback-only.protected voidsetSavepoint(Object savepoint)Set a savepoint for this transaction.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.transaction.TransactionStatus
isNewTransaction
构造器详细资料
AbstractTransactionStatus
public AbstractTransactionStatus()
方法详细资料
setRollbackOnly
public void setRollbackOnly()
从接口复制的说明:TransactionStatusSet 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
TransactionTemplateorTransactionInterceptor, where the actual commit/rollback decision is made by the container.
isRollbackOnly
public 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.
isLocalRollbackOnly
public boolean isLocalRollbackOnly()
Determine the rollback-only flag via checking this TransactionStatus.Will only return "true" if the application called
setRollbackOnlyon this TransactionStatus object.
isGlobalRollbackOnly
public boolean isGlobalRollbackOnly()
Template method for determining the global rollback-only flag of the underlying transaction, if any.This implementation always returns
false.
flush
public void flush()
This implementations is empty, considering flush as a no-op.- 指定者:
flush在接口中Flushable- 指定者:
flush在接口中TransactionStatus
setCompleted
public void setCompleted()
Mark this transaction as completed, that is, committed or rolled back.
isCompleted
public boolean isCompleted()
从接口复制的说明:TransactionStatusReturn whether this transaction is completed, that is, whether it has already been committed or rolled back.
setSavepoint
protected void setSavepoint(Object savepoint)
Set a savepoint for this transaction. Useful for PROPAGATION_NESTED.
getSavepoint
protected Object getSavepoint()
Get the savepoint for this transaction, if any.
hasSavepoint
public boolean hasSavepoint()
从接口复制的说明: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
TransactionStatus.isNewTransaction(). For programmatic handling of custom savepoints, use the operations provided bySavepointManager.
createAndHoldSavepoint
public void createAndHoldSavepoint() throws TransactionException
Create a savepoint and hold it for the transaction.- 抛出:
NestedTransactionNotSupportedException- if the underlying transaction does not support savepointsTransactionException
rollbackToHeldSavepoint
public void rollbackToHeldSavepoint() throws TransactionException
Roll back to the savepoint that is held for the transaction and release the savepoint right afterwards.
releaseHeldSavepoint
public void releaseHeldSavepoint() throws TransactionException
Release the savepoint that is held for the transaction.