Interface TransactionExecution
- All Known Subinterfaces:
ReactiveTransaction, TransactionStatus
- All Known Implementing Classes:
AbstractTransactionStatus, DefaultTransactionStatus, GenericReactiveTransaction, SimpleTransactionStatus
TransactionStatus as well as
ReactiveTransaction, and as of 6.1 also as transaction
representation for TransactionExecutionListener.- Since:
- 5.2
- Author:
- Juergen Hoeller
-
Method Summary
Modifier and TypeMethodDescriptiondefault StringReturn the defined name of the transaction (possibly an empty String).default booleanReturn whether there is an actual transaction active: this is meant to cover a new transaction as well as participation in an existing transaction, only returningfalsewhen not running in an actual transaction at all.default booleanReturn whether this transaction is completed, that is, whether it has already been committed or rolled back.default booleanisNested()Return if this transaction executes in a nested fashion within another.default booleanReturn whether the transaction manager considers the present transaction as new; otherwise participating in an existing transaction, or potentially not running in an actual transaction in the first place.default booleanReturn if this transaction is defined as read-only transaction.default booleanReturn whether the transaction has been marked as rollback-only (either by the application or by the transaction infrastructure).default voidSet the transaction rollback-only.
-
Method Details
-
getTransactionName
Return the defined name of the transaction (possibly an empty String).In case of Spring's declarative transactions, the exposed name will be the
fully-qualified class name + "." + method name(by default).The default implementation returns an empty String.
- Since:
- 6.1
- See Also:
-
hasTransaction
default boolean hasTransaction()Return whether there is an actual transaction active: this is meant to cover a new transaction as well as participation in an existing transaction, only returningfalsewhen not running in an actual transaction at all.The default implementation returns
true.- Since:
- 6.1
- See Also:
-
isNewTransaction
default boolean isNewTransaction()Return whether the transaction manager considers the present transaction as new; otherwise participating in an existing transaction, or potentially not running in an actual transaction in the first place.This is primarily here for transaction manager state handling. Prefer the use of
hasTransaction()for application purposes since this is usually semantically appropriate.The "new" status can be transaction manager specific, for example, returning
truefor an actual nested transaction but potentiallyfalsefor a savepoint-based nested transaction scope if the savepoint management is explicitly exposed (such as onTransactionStatus). A combined check for any kind of nested execution is provided byisNested().The default implementation returns
true.- See Also:
-
isNested
default boolean isNested()Return if this transaction executes in a nested fashion within another.The default implementation returns
false.- Since:
- 6.1
- See Also:
-
isReadOnly
default boolean isReadOnly()Return if this transaction is defined as read-only transaction.The default implementation returns
false.- Since:
- 6.1
- See Also:
-
setRollbackOnly
default 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.The default implementation throws an UnsupportedOperationException.
- See Also:
-
isRollbackOnly
default boolean isRollbackOnly()Return whether the transaction has been marked as rollback-only (either by the application or by the transaction infrastructure).The default implementation returns
false.- See Also:
-
isCompleted
default boolean isCompleted()Return whether this transaction is completed, that is, whether it has already been committed or rolled back.The default implementation returns
false.
-