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 |
|---|---|
| public <T> T | Returns: a result object returned by the callback, ornull if nonethe callback object that specifies the transactional action action)Execute the action specified by the given callback object within a transaction. |
| public default void | executeWithoutResult(Consumer<TransactionStatus>
the Runnable that specifies the transactional action action)Execute the action specified by the given |
| public static TransactionOperations | withoutTransaction()
Return an implementation of the |
| execute | back to summary |
|---|---|
| public <T> T execute(TransactionCallback<T> action) throws TransactionException Execute the action specified by the given callback object within a transaction. 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.
| |
| executeWithoutResult | back to summary |
|---|---|
| public default void executeWithoutResult(Consumer<TransactionStatus> action) throws TransactionException Execute the action specified by the given If you need to return an object from the callback or access the
This variant is analogous to using a
| |
| withoutTransaction | back to summary |
|---|---|
| public static TransactionOperations withoutTransaction() Return an implementation of the Useful for testing: The behavior is equivalent to running with a transaction manager with no actual transaction (PROPAGATION_SUPPORTS) and no synchronization (SYNCHRONIZATION_NEVER). For a | |