Top Description Methods
org.springframework.transaction

public Interface TransactionExecution

Known Direct Subinterfaces
org.springframework.transaction.TransactionStatus, org.springframework.transaction.ReactiveTransaction

Common representation of the current state of a transaction. Serves as base interface for TransactionStatus as well as ReactiveTransaction, and as of 6.1 also as transaction representation for TransactionExecutionListener.
Author
Juergen Hoeller
Since
5.2

Method Summary

Modifier and TypeMethod and Description
public default String
getTransactionName()

Return the defined name of the transaction (possibly an empty String).

public 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 returning false when not running in an actual transaction at all.

public default boolean
isCompleted()

Return whether this transaction is completed, that is, whether it has already been committed or rolled back.

public default boolean
isNested()

Return if this transaction executes in a nested fashion within another.

public 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.

public default boolean
isReadOnly()

Return if this transaction is defined as read-only transaction.

public default boolean
isRollbackOnly()

Return whether the transaction has been marked as rollback-only (either by the application or by the transaction infrastructure).

public default void
setRollbackOnly()

Set the transaction rollback-only.

Method Detail

getTransactionNameback to summary
public default String 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
TransactionDefinition#getName()
hasTransactionback to summary
public 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 returning false when not running in an actual transaction at all.

The default implementation returns true.

Since
6.1
See Also
isNewTransaction(), isNested(), isReadOnly()
isCompletedback to summary
public 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.

isNestedback to summary
public default boolean isNested()

Return if this transaction executes in a nested fashion within another.

The default implementation returns false.

Since
6.1
See Also
hasTransaction(), isNewTransaction(), TransactionDefinition#PROPAGATION_NESTED
isNewTransactionback to summary
public 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, e.g. returning true for an actual nested transaction but potentially false for a savepoint-based nested transaction scope if the savepoint management is explicitly exposed (such as on TransactionStatus). A combined check for any kind of nested execution is provided by isNested().

The default implementation returns true.

See Also
hasTransaction(), isNested(), TransactionStatus#hasSavepoint()
isReadOnlyback to summary
public default boolean isReadOnly()

Return if this transaction is defined as read-only transaction.

The default implementation returns false.

Since
6.1
See Also
TransactionDefinition#isReadOnly()
isRollbackOnlyback to summary
public 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
setRollbackOnly()
setRollbackOnlyback to summary
public 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()