Package com.gruelbox.transactionoutbox
Interface Transaction
- All Known Implementing Classes:
SimpleTransaction
public interface Transaction
Access and manipulation of a currently-active transaction.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPostCommitHook
(Runnable runnable) Will be called to perform work immediately after the current transaction is committed.default <T> T
context()
Creates a prepared statement which will be cached and re-used within a transaction.
-
Method Details
-
connection
Connection connection()- Returns:
- The connection for the transaction.
-
context
default <T> T context()- Type Parameters:
T
- The context type. Coerced on read.- Returns:
- A
TransactionManager
-specific object representing the context of this transaction. Intended for use withTransactionManager
implementations that support explicitly-passed transaction context injection into method arguments.
-
prepareBatchStatement
Creates a prepared statement which will be cached and re-used within a transaction. Any batch on these statements is executed before the transaction is committed, and automatically closed.- Parameters:
sql
- The SQL statement- Returns:
- The statement.
-
addPostCommitHook
Will be called to perform work immediately after the current transaction is committed. This should occur in the same thread and will generally not be long-lasting.- Parameters:
runnable
- The code to run post-commit.
-