Class TransactionExecuter
Recommendation: Use instances of this executor instead of the two static methods.
Instances can be obtained using ITransactionService.execute()
.
Note: The executor instance creates read-only transactions by default (see write()
).
- Since:
- 3.5.2
-
Constructor Summary
ConstructorDescriptionTransactionExecuter
(ITransactionService transactionService) For internal use only. -
Method Summary
Modifier and TypeMethodDescription<R> R
Executes the callable in a transaction.static <T> T
execute
(RunnableWEx<T> runnable) Executes the runnable inside the transaction.static <T> T
executeSafely
(RunnableWEx<T> runnable) Executes the runnable inside the transaction.By default the executor will fail if its terminal method is executed in a transaction context.void
Executes the runnable in a transaction.<R> R
Executes the supplier in a transaction and returns its result.write()
By default the transactions are read-only.
-
Constructor Details
-
TransactionExecuter
For internal use only. UseITransactionService.execute()
to get an instance.- Since:
- 3.18.0
-
-
Method Details
-
write
By default the transactions are read-only. Use this method to execute write transactions by this executor.- Since:
- 3.18.0
-
reuseExistingTransaction
By default the executor will fail if its terminal method is executed in a transaction context. If that is the case, use this method to reuse the existing transaction.In this scenario, the executor will not be able to influence the transaction type (read-only or write), and
write()
calls will be ignored.- Since:
- 3.18.0
-
runnable
Executes the runnable in a transaction.This is a terminal method for this executor. Multiple terminal methods can be called to execute multiple transactions using the same executor.
- Since:
- 3.18.0
-
callable
Executes the callable in a transaction.This is a terminal method for this executor. Multiple terminal methods can be called to execute multiple transactions using the same executor.
- Since:
- 3.24.4
-
supplier
Executes the supplier in a transaction and returns its result.This is a terminal method for this executor. Multiple terminal methods can be called to execute multiple transactions using the same executor.
- Since:
- 3.18.0
-
execute
Executes the runnable inside the transaction. Recommendation: Use the executor instance instead of this static method wherever possible. -
executeSafely
Executes the runnable inside the transaction. It will not create a new transaction if one exists or cannot be created or when the platform is not initialized. (So the invocation will never fail due to a transaction-related problem.)Recommendation: Use the executor instance instead of this static method wherever possible.
- Since:
- 3.7.1
- See Also:
-