public interface TransactionManager
Modifier and Type | Method and Description |
---|---|
default void |
executeInTransaction(Runnable task)
Executes the given
task in a new Transaction . |
default <T> T |
fetchInTransaction(Supplier<T> supplier)
Invokes the given
supplier in a transaction managed by the current TransactionManager. |
Transaction |
startTransaction()
Starts a transaction.
|
Transaction startTransaction()
default void executeInTransaction(Runnable task)
task
in a new Transaction
. The transaction is committed when the task
completes normally, and rolled back when it throws an exception.task
- The task to executedefault <T> T fetchInTransaction(Supplier<T> supplier)
supplier
in a transaction managed by the current TransactionManager. Upon completion
of the call, the transaction will be committed in the case of a regular return value, or rolled back in case an
exception occurred.
This method is an alternative to executeInTransaction(Runnable)
in cases where a result needs to be
returned from the code to be executed transactionally.
T
- The type of value to returnsupplier
- The supplier of the value to returnCopyright © 2010–2018. All rights reserved.