Interface Transactional<This extends Transactional<This>>
- Type Parameters:
 This- must match the interface that is extending theTransactionalinterface.
- All Superinterfaces:
 SqlObject
A mixin interface to expose transaction methods on the sql object.
 
 Use caution with on-demand Transactional instances.
 Handle throws TransactionException if closed while a
 transaction is open. Since on-demand extensions open and close a handle around each method invocation, calling
 begin() on an on-demand Transactional will always leave a transaction open, and thus
 always throw this exception.
 
 Users of on-demand Transactional instances should use the inTransaction and useTransaction
 methods to execute transactions. It is safe to call other Transactional methods from inside these callbacks.
- 
Method Summary
Modifier and TypeMethodDescriptiondefault voidbegin()Begins a transaction.default voidcommit()Commits the open transaction.default <R,X extends Exception> 
RinTransaction(TransactionIsolationLevel isolation, TransactionalCallback<R, This, X> callback) Executes the given callback within a transaction, returning the value returned by the callback.default <R,X extends Exception> 
RinTransaction(TransactionalCallback<R, This, X> callback) Executes the given callback within a transaction, returning the value returned by the callback.default booleanReturns True if this object is currently in a transaction.default voidreleaseSavepoint(String savepointName) Releases the given savepoint.default voidrollback()Rolls back the open transaction.default voidrollbackToSavepoint(String savepointName) Rolls back to the given savepoint.default voidCreates a savepoint with the given name on the transaction.default <X extends Exception>
voiduseTransaction(TransactionIsolationLevel isolation, TransactionalConsumer<This, X> callback) Executes the given callback within a transaction.default <X extends Exception>
voiduseTransaction(TransactionalConsumer<This, X> callback) Executes the given callback within a transaction.Methods inherited from interface org.jdbi.v3.sqlobject.SqlObject
getHandle, useHandle, withHandle 
- 
Method Details
- 
begin
default void begin()Begins a transaction.- Throws:
 TransactionException- if called on an on-demand Transactional instance.
 - 
commit
default void commit()Commits the open transaction. - 
rollback
default void rollback()Rolls back the open transaction. - 
isInTransaction
default boolean isInTransaction()Returns True if this object is currently in a transaction.- Returns:
 - True if the object is in a transaction.
 
 - 
savepoint
Creates a savepoint with the given name on the transaction.- Parameters:
 savepointName- the savepoint name.
 - 
rollbackToSavepoint
Rolls back to the given savepoint.- Parameters:
 savepointName- the savepoint name.
 - 
releaseSavepoint
Releases the given savepoint.- Parameters:
 savepointName- the savepoint name.
 - 
inTransaction
Executes the given callback within a transaction, returning the value returned by the callback.- Type Parameters:
 R- method return typeX- exception optionally thrown by the callback.- Parameters:
 callback- the callback to execute- Returns:
 - the value returned by the callback.
 - Throws:
 X- any exception thrown by the callback.
 - 
inTransaction
default <R,X extends Exception> R inTransaction(TransactionIsolationLevel isolation, TransactionalCallback<R, This, throws XX> callback) Executes the given callback within a transaction, returning the value returned by the callback.- Type Parameters:
 R- method return typeX- exception optionally thrown by the callback.- Parameters:
 isolation- the transaction isolation level.callback- the callback to execute- Returns:
 - the value returned by the callback.
 - Throws:
 X- any exception thrown by the callback.
 - 
useTransaction
Executes the given callback within a transaction.- Type Parameters:
 X- exception optionally thrown by the callback.- Parameters:
 callback- the callback to execute- Throws:
 X- any exception thrown by the callback.
 - 
useTransaction
default <X extends Exception> void useTransaction(TransactionIsolationLevel isolation, TransactionalConsumer<This, X> callback) throws XExecutes the given callback within a transaction.- Type Parameters:
 X- exception optionally thrown by the callback.- Parameters:
 isolation- the transaction isolation level.callback- the callback to execute- Throws:
 X- any exception thrown by the callback.
 
 -