Class NoOpTransactionHandler
java.lang.Object
org.jdbi.v3.core.transaction.NoOpTransactionHandler
- All Implemented Interfaces:
TransactionHandler
- Direct Known Subclasses:
CMTTransactionHandler
A
TransactionHandler for connections whose transactions are managed
completely outside of Jdbi, for example by a proxy data source or an XA
transaction manager. This handler never reads or changes the transaction
state of the connection:
begin(Handle)andcommit(Handle)do nothing. The external manager decides when a transaction starts and when it commits.rollback(Handle)throws aTransactionException. Jdbi cannot roll the external transaction back, so the exception propagates to the external manager, which then does the rollback.isInTransaction(Handle)returns false and does not examine the connection. On a wrapped connection, the autocommit flag does not show the real transaction state, so this handler never reads it.inTransaction(Handle, HandleCallback)runs the callback on the handle directly.- Savepoints are not supported.
Handle.afterCommit, Handle.afterRollback) cannot
be registered under this handler.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier 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) Savepoints are not supported.voidCalled when a transaction is rolled back.voidrollbackToSavepoint(Handle handle, String name) Savepoints are not supported.voidSavepoints are not supported.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TransactionHandler
specialize
-
Constructor Details
-
NoOpTransactionHandler
public NoOpTransactionHandler()
-
-
Method Details
-
begin
Description copied from interface:TransactionHandlerBegin a transaction.- Specified by:
beginin interfaceTransactionHandler- Parameters:
handle- the handle the transaction is being started on
-
commit
Description copied from interface:TransactionHandlerCommit the transaction.- Specified by:
commitin interfaceTransactionHandler- Parameters:
handle- the handle the commit is being performed on
-
rollback
Called when a transaction is rolled back. Will throw a RuntimeException to force transactional rollback.- Specified by:
rollbackin interfaceTransactionHandler- Parameters:
handle- the handle the rollback is being performed on
-
isInTransaction
Description copied from interface:TransactionHandlerReturns whether a given Handle is in the transaction.- Specified by:
isInTransactionin interfaceTransactionHandler- Parameters:
handle- the handle to test- Returns:
- whether the given handle is in a transaction
-
savepoint
Savepoints are not supported.- Specified by:
savepointin interfaceTransactionHandler- Parameters:
handle- the handle on which the transaction is being savepointedname- The name of the savepoint, used to rollback to or release later
-
rollbackToSavepoint
Savepoints are not supported.- Specified by:
rollbackToSavepointin interfaceTransactionHandler- Parameters:
handle- the handle the rollback is being performed onname- the name of the savepoint to rollback to
-
releaseSavepoint
Savepoints are not supported.- Specified by:
releaseSavepointin interfaceTransactionHandler- Parameters:
handle- the handle on which the savepoint is being releasedsavepointName- the savepoint to release
-
inTransaction
public <R, X extends Exception> R inTransaction(Handle handle, HandleCallback<R, X> callback) throws XDescription copied from interface:TransactionHandlerRun a transaction.- Specified by:
inTransactionin interfaceTransactionHandler- 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:TransactionHandlerRun a transaction.- Specified by:
inTransactionin interfaceTransactionHandler- 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:
-