接口 TransactionStatus
- 所有超级接口:
Flushable
,SavepointManager
public interface TransactionStatus extends SavepointManager, Flushable
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).
Includes the
SavepointManager
interface to provide access to savepoint management facilities. Note that savepoint management is only available if supported by the underlying transaction manager.
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 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; otherwise 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.从接口继承的方法 org.springframework.transaction.SavepointManager
createSavepoint, releaseSavepoint, rollbackToSavepoint
方法详细资料
isNewTransaction
boolean isNewTransaction()
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.
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 the operations provided bySavepointManager
.
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
orTransactionInterceptor
, where the actual commit/rollback decision is made by the container.
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.This is effectively just a hint and may be a no-op if the underlying transaction manager does not have a flush concept. A flush signal may get applied to the primary resource or to transaction synchronizations, depending on the underlying resource.
isCompleted
boolean isCompleted()
Return whether this transaction is completed, that is, whether it has already been committed or rolled back.