Package com.avoka.fc.core.util
Class TxnExecutor
java.lang.Object
com.avoka.fc.core.util.TxnExecutor
Provides a Cayenne Transaction Executor class, which will execute the specified
function in a Cayenne Transaction.
- Since:
- 4.0.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Provides a closure function to call in the transaction executor. -
Constructor Summary
ConstructorDescriptionTxnExecutor
(Class callingClass, String errorType) Create a Transaction Executor object with the given logger.TxnExecutor
(Class callingClass, String errorType, int transactionIsolation, boolean readOnly) Create a Transaction Executor object with the given logger. -
Method Summary
Modifier and TypeMethodDescriptionexecute
(TxnExecutor.IFunction function) Execute the given function inside a Cayenne transaction.
-
Constructor Details
-
TxnExecutor
Create a Transaction Executor object with the given logger.- Parameters:
callingClass
- the class calling the service, used for error logging purposeserrorType
- the error type to log (required)
-
TxnExecutor
public TxnExecutor(Class callingClass, String errorType, int transactionIsolation, boolean readOnly) Create a Transaction Executor object with the given logger.- Parameters:
callingClass
- the class calling the service, used for error logging purposeserrorType
- the error type to log (required)transactionIsolation
- the transaction isolation levelreadOnly
- the connection ready only flag- Since:
- 4.3.4
-
-
Method Details
-
execute
Execute the given function inside a Cayenne transaction. If an error occurs that is a RuntimeException, it will be thrown as is; other errors will be wrapped in an ApplicationException.- Parameters:
function
- the function to execute- Returns:
- the function result if successful
- Throws:
ApplicationException
- if an error occurs executing the function or performing a transaction commit
-