- All Known Implementing Classes:
DefaultTransactionProvider
,NoTransactionProvider
,ThreadLocalTransactionProvider
TransactionProvider
SPI can be used to implement custom
transaction
behaviour that is applied when calling
DSLContext.transactionResult(TransactionalCallable)
or
DSLContext.transaction(TransactionalRunnable)
.
A new Configuration
copy is created from the calling
DSLContext
for the scope of a single transactions. Implementors may
freely add custom data to Configuration.data()
, in order to share
information between begin(TransactionContext)
and
commit(TransactionContext)
or rollback(TransactionContext)
,
as well as to share information with nested transactions.
Implementors may freely choose whether they support nested transactions. An
example implementation supporting nested transactions is
DefaultTransactionProvider
, which implements such transactions using
JDBC Savepoint
s.
- Author:
- Lukas Eder
-
Method Summary
Modifier and TypeMethodDescriptionvoid
begin(TransactionContext ctx)
Begin a new transaction.void
commit(TransactionContext ctx)
Commit a transaction.void
rollback(TransactionContext ctx)
Rollback a transaction.
-
Method Details
-
begin
Begin a new transaction.This method begins a new transaction with a
Configuration
scoped for this transaction. The resultingTransaction
object may be used by implementors to identify the transaction whencommit(TransactionContext)
orrollback(TransactionContext)
is called.- Parameters:
ctx
- the configuration scoped to this transaction and its nested transactions.- Throws:
DataAccessException
- Any exception issued by the underlying database.
-
commit
Commit a transaction.- Parameters:
ctx
- the configuration scoped to this transaction and its nested transactions.- Throws:
DataAccessException
- Any exception issued by the underlying database.
-
rollback
Rollback a transaction.- Parameters:
ctx
- the configuration scoped to this transaction and its nested transactions.- Throws:
DataAccessException
- Any exception issued by the underlying database.
-