Package org.jdbi.v3.core.transaction
Class LocalTransactionHandler
- java.lang.Object
-
- org.jdbi.v3.core.transaction.LocalTransactionHandler
-
- All Implemented Interfaces:
TransactionHandler
- Direct Known Subclasses:
LocalTransactionHandler.BindingLocalTransactionHandler
public class LocalTransactionHandler extends java.lang.Object implements TransactionHandler
ThisTransactionHandleruses local JDBC transactions demarcated explicitly on the handle and passed through to be handled directly on the JDBC Connection instance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classLocalTransactionHandler.BindingLocalTransactionHandler(package private) static classLocalTransactionHandler.BoundLocalTransactionHandler
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<Handle,LocalTransactionHandler.BoundLocalTransactionHandler>bound
-
Constructor Summary
Constructors Constructor Description LocalTransactionHandler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbegin(Handle handle)Begin a transaction.static LocalTransactionHandlerbinding()voidcommit(Handle handle)Commit the transaction.<R,X extends java.lang.Exception>
RinTransaction(Handle handle, HandleCallback<R,X> callback)Run a transaction.<R,X extends java.lang.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.(package private) TransactionHandlernonspecial(Handle handle)voidreleaseSavepoint(Handle handle, java.lang.String savepointName)Release a previously created savepoint.voidrollback(Handle handle)Roll back the transaction.voidrollbackToSavepoint(Handle handle, java.lang.String savepointName)Roll back to a named savepoint.voidsavepoint(Handle handle, java.lang.String savepointName)Create a new savepoint.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jdbi.v3.core.transaction.TransactionHandler
specialize
-
-
-
-
Field Detail
-
bound
private final java.util.Map<Handle,LocalTransactionHandler.BoundLocalTransactionHandler> bound
-
-
Method Detail
-
begin
public void begin(Handle handle)
Description copied from interface:TransactionHandlerBegin a transaction.- Specified by:
beginin interfaceTransactionHandler- Parameters:
handle- the handle the transaction is being started on
-
commit
public void commit(Handle handle)
Description copied from interface:TransactionHandlerCommit the transaction.- Specified by:
commitin interfaceTransactionHandler- Parameters:
handle- the handle the commit is being performed on
-
rollback
public void rollback(Handle handle)
Description copied from interface:TransactionHandlerRoll back the transaction.- Specified by:
rollbackin interfaceTransactionHandler- Parameters:
handle- the handle the rollback is being performed on
-
isInTransaction
public boolean isInTransaction(Handle handle)
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
public void savepoint(Handle handle, java.lang.String savepointName)
Description copied from interface:TransactionHandlerCreate a new savepoint.- Specified by:
savepointin interfaceTransactionHandler- Parameters:
handle- the handle on which the transaction is being savepointedsavepointName- The name of the savepoint, used to rollback to or release later
-
rollbackToSavepoint
public void rollbackToSavepoint(Handle handle, java.lang.String savepointName)
Description copied from interface:TransactionHandlerRoll back to a named savepoint.- Specified by:
rollbackToSavepointin interfaceTransactionHandler- Parameters:
handle- the handle the rollback is being performed onsavepointName- the name of the savepoint to rollback to
-
releaseSavepoint
public void releaseSavepoint(Handle handle, java.lang.String savepointName)
Description copied from interface:TransactionHandlerRelease a previously created savepoint.- Specified by:
releaseSavepointin interfaceTransactionHandler- Parameters:
handle- the handle on which the savepoint is being releasedsavepointName- the savepoint to release
-
inTransaction
public <R,X extends java.lang.Exception> R inTransaction(Handle handle, HandleCallback<R,X> callback) throws X extends java.lang.Exception
Description 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.X extends java.lang.Exception- See Also:
Handle.inTransaction(HandleCallback)
-
inTransaction
public <R,X extends java.lang.Exception> R inTransaction(Handle handle, TransactionIsolationLevel level, HandleCallback<R,X> callback) throws X extends java.lang.Exception
Description 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.X extends java.lang.Exception- See Also:
Handle.inTransaction(TransactionIsolationLevel, HandleCallback)
-
nonspecial
TransactionHandler nonspecial(Handle handle)
-
binding
public static LocalTransactionHandler binding()
-
-