public interface TransactionOperations
TransactionTemplate. Not often used directly, but a useful option to enhance testability, as it can easily be mocked or stubbed.
|Modifier and Type||Method and Description|
Execute the action specified by the given
Execute the action specified by the given callback object within a transaction.
Return an implementation of the
@Nullable <T> T execute(TransactionCallback<T> action) throws TransactionException
Allows for returning a result object created within the transaction, that is, a domain object or a collection of domain objects. A RuntimeException thrown by the callback is treated as a fatal exception that enforces a rollback. Such an exception gets propagated to the caller of the template.
default void execute(Runnable action) throws TransactionException
Runnablewithin a transaction.
This variant is analogous to using a
but with a simplified signature for common cases - and conveniently usable with
Java 8 lambda expressions.
static TransactionOperations withoutTransaction()
TransactionOperationsinterface which executes a given
TransactionCallbackwithout an actual transaction.
Useful for testing: The behavior is equivalent to running with a transaction manager with no actual transaction (PROPAGATION_SUPPORTS) and no synchronization (SYNCHRONIZATION_NEVER).