Class SimpleTransaction
java.lang.Object
com.gruelbox.transactionoutbox.spi.SimpleTransaction
- All Implemented Interfaces:
Transaction
,AutoCloseable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPostCommitHook
(Runnable runnable) Will be called to perform work immediately after the current transaction is committed.void
close()
void
commit()
<T> T
context()
void
Creates a prepared statement which will be cached and re-used within a transaction.void
void
rollback()
-
Constructor Details
-
SimpleTransaction
-
-
Method Details
-
connection
- Specified by:
connection
in interfaceTransaction
- Returns:
- The connection for the transaction.
-
addPostCommitHook
Description copied from interface:Transaction
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.- Specified by:
addPostCommitHook
in interfaceTransaction
- Parameters:
runnable
- The code to run post-commit.
-
prepareBatchStatement
Description copied from interface:Transaction
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.- Specified by:
prepareBatchStatement
in interfaceTransaction
- Parameters:
sql
- The SQL statement- Returns:
- The statement.
-
flushBatches
public void flushBatches() -
processHooks
public void processHooks() -
commit
public void commit() -
rollback
- Throws:
SQLException
-
context
public <T> T context()- Specified by:
context
in interfaceTransaction
- 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.
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-