Package org.jdbi.v3.core.transaction
Class SerializableTransactionRunner
java.lang.Object
org.jdbi.v3.core.transaction.DelegatingTransactionHandler
org.jdbi.v3.core.transaction.SerializableTransactionRunner
- All Implemented Interfaces:
TransactionHandler
public class SerializableTransactionRunner
extends DelegatingTransactionHandler
implements TransactionHandler
A TransactionHandler that automatically retries transactions that fail due to
serialization failures, which can generally be resolved by automatically
retrying the transaction. Any HandleCallback used under this runner
should be aware that it may be invoked multiple times and should be idempotent.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Configuration for serializable transaction runner. -
Constructor Summary
ConstructorDescription -
Method Summary
Modifier and TypeMethodDescription<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.specialize
(Handle handle) Bind a TransactionHandler to a Handle, to allow it to track handle-local state.Methods inherited from class org.jdbi.v3.core.transaction.DelegatingTransactionHandler
begin, commit, isInTransaction, releaseSavepoint, rollback, rollbackToSavepoint, savepoint
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jdbi.v3.core.transaction.TransactionHandler
begin, commit, isInTransaction, releaseSavepoint, rollback, rollbackToSavepoint, savepoint
-
Constructor Details
-
SerializableTransactionRunner
public SerializableTransactionRunner() -
SerializableTransactionRunner
-
-
Method Details
-
inTransaction
public <R,X extends Exception> R inTransaction(Handle handle, HandleCallback<R, X> callback) throws XDescription copied from interface:TransactionHandler
Run a transaction.- Specified by:
inTransaction
in interfaceTransactionHandler
- Overrides:
inTransaction
in classDelegatingTransactionHandler
- Type Parameters:
R
- the callback return typeX
- the exception type thrown by the callback, if any- Parameters:
handle
- the handle to the databasecallback
- 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
public <R,X extends Exception> R inTransaction(Handle handle, TransactionIsolationLevel level, HandleCallback<R, X> callback) throws XDescription copied from interface:TransactionHandler
Run a transaction.- Specified by:
inTransaction
in interfaceTransactionHandler
- Overrides:
inTransaction
in classDelegatingTransactionHandler
- Type Parameters:
R
- the callback return typeX
- the exception type thrown by the callback, if any- Parameters:
handle
- the handle to the databaselevel
- the isolation level for the transactioncallback
- 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:
-
specialize
Description copied from interface:TransactionHandler
Bind a TransactionHandler to a Handle, to allow it to track handle-local state.- Specified by:
specialize
in interfaceTransactionHandler
- Parameters:
handle
- the handle to bind to- Returns:
- the bound TransactionHandler
- Throws:
SQLException
- bad things happened
-