public interface TransactionProvider
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.
Modifier and Type | Method and Description |
---|---|
void |
begin(TransactionContext ctx)
Begin a new transaction.
|
void |
commit(TransactionContext ctx) |
void |
rollback(TransactionContext ctx) |
void begin(TransactionContext ctx) throws DataAccessException
This method begins a new transaction with a Configuration
scoped
for this transaction. The resulting Transaction
object may be
used by implementors to identify the transaction when
commit(TransactionContext)
or
rollback(TransactionContext)
is called.
Configuration
- the configuration scoped to this transaction and its
nested transactions.DataAccessException
- Any exception issued by the underlying
database.void commit(TransactionContext ctx) throws DataAccessException
Configuration
- the configuration scoped to this transaction and its
nested transactions.transaction
- The user-defined transaction object returned from
begin(TransactionContext)
. May be null
.DataAccessException
- Any exception issued by the underlying
database.void rollback(TransactionContext ctx) throws DataAccessException
Configuration
- the configuration scoped to this transaction and its
nested transactions.transaction
- The user-defined transaction object returned from
begin(TransactionContext)
. May be null
.cause
- The exception that has caused the rollback.DataAccessException
- Any exception issued by the underlying
database.Copyright © 2017. All Rights Reserved.