Package org.jdbi.v3.core.transaction
Interface TransactionHandler
- All Known Implementing Classes:
- CMTTransactionHandler,- DelegatingTransactionHandler,- LocalTransactionHandler,- RollbackOnlyTransactionHandler,- SerializableTransactionRunner
public interface TransactionHandler
Interface which defines callbacks to be used when transaction methods are called on a handle.
 Used by specifying on a 
Jdbi instance. All Handle instances
 opened from that Jdbi will use the handler specified.
 
 The default implementation, LocalTransactionHandler, explicitly manages
 the transactions on the underlying JDBC Connection.
 
- 
Method SummaryModifier and TypeMethodDescriptionvoidBegin a transaction.voidCommit the transaction.<R,X extends Exception> 
 RinTransaction(Handle handle, HandleCallback<R, X> callback) Run a transaction.<R,X extends Exception> 
 RinTransaction(Handle handle, TransactionIsolationLevel level, HandleCallback<R, X> callback) Run a transaction.booleanisInTransaction(Handle handle) Returns whether a given Handle is in the transaction.voidreleaseSavepoint(Handle handle, String savepointName) Release a previously created savepoint.voidRoll back the transaction.voidrollbackToSavepoint(Handle handle, String savepointName) Roll back to a named savepoint.voidCreate a new savepoint.default TransactionHandlerspecialize(Handle handle) Bind a TransactionHandler to a Handle, to allow it to track handle-local state.
- 
Method Details- 
beginBegin a transaction.- Parameters:
- handle- the handle the transaction is being started on
 
- 
commitCommit the transaction.- Parameters:
- handle- the handle the commit is being performed on
 
- 
rollbackRoll back the transaction.- Parameters:
- handle- the handle the rollback is being performed on
 
- 
isInTransactionReturns whether a given Handle is in the transaction.- Parameters:
- handle- the handle to test
- Returns:
- whether the given handle is in a transaction
 
- 
savepointCreate a new savepoint.- Parameters:
- handle- the handle on which the transaction is being savepointed
- savepointName- The name of the savepoint, used to rollback to or release later
 
- 
rollbackToSavepointRoll back to a named savepoint.- Parameters:
- handle- the handle the rollback is being performed on
- savepointName- the name of the savepoint to rollback to
 
- 
releaseSavepointRelease a previously created savepoint.- Parameters:
- handle- the handle on which the savepoint is being released
- savepointName- the savepoint to release
 
- 
inTransactionRun a transaction.- Type Parameters:
- R- the callback return type
- X- the exception type thrown by the callback, if any
- Parameters:
- handle- the handle to the database
- callback- a callback which will receive the open handle, in a transaction.
- Returns:
- the value returned by the callback.
- Throws:
- X- any exception thrown by the callback.
- See Also:
 
- 
inTransaction<R,X extends Exception> R inTransaction(Handle handle, TransactionIsolationLevel level, HandleCallback<R, X> callback) throws XRun a transaction.- Type Parameters:
- R- the callback return type
- X- the exception type thrown by the callback, if any
- Parameters:
- handle- the handle to the database
- level- the isolation level for the transaction
- callback- a callback which will receive the open handle, in a transaction.
- Returns:
- the value returned by the callback.
- Throws:
- X- any exception thrown by the callback.
- See Also:
 
- 
specializeBind a TransactionHandler to a Handle, to allow it to track handle-local state.- Parameters:
- handle- the handle to bind to
- Returns:
- the bound TransactionHandler
- Throws:
- SQLException- bad things happened
 
 
-