Package org.jdbi.v3.core.transaction
Class LocalTransactionHandler
java.lang.Object
org.jdbi.v3.core.transaction.LocalTransactionHandler
- All Implemented Interfaces:
TransactionHandler
This
TransactionHandler
uses local JDBC transactions
demarcated explicitly on the handle and passed through to be handled
directly on the JDBC Connection instance.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Begin a transaction.static LocalTransactionHandler
binding()
void
Commit 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.boolean
isInTransaction
(Handle handle) Returns whether a given Handle is in the transaction.void
releaseSavepoint
(Handle handle, String savepointName) Release a previously created savepoint.void
void
Roll back the transaction.void
rollbackToSavepoint
(Handle handle, String savepointName) Roll back to a named savepoint.void
Create a new 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
specialize
-
Constructor Details
-
LocalTransactionHandler
public LocalTransactionHandler()
-
-
Method Details
-
begin
Description copied from interface:TransactionHandler
Begin a transaction.- Specified by:
begin
in interfaceTransactionHandler
- Parameters:
handle
- the handle the transaction is being started on
-
commit
Description copied from interface:TransactionHandler
Commit the transaction.- Specified by:
commit
in interfaceTransactionHandler
- Parameters:
handle
- the handle the commit is being performed on
-
rollback
Description copied from interface:TransactionHandler
Roll back the transaction.- Specified by:
rollback
in interfaceTransactionHandler
- Parameters:
handle
- the handle the rollback is being performed on
-
isInTransaction
Description copied from interface:TransactionHandler
Returns whether a given Handle is in the transaction.- Specified by:
isInTransaction
in interfaceTransactionHandler
- Parameters:
handle
- the handle to test- Returns:
- whether the given handle is in a transaction
-
savepoint
Description copied from interface:TransactionHandler
Create a new savepoint.- Specified by:
savepoint
in 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
Description copied from interface:TransactionHandler
Roll back to a named savepoint.- Specified by:
rollbackToSavepoint
in interfaceTransactionHandler
- Parameters:
handle
- the handle the rollback is being performed onsavepointName
- the name of the savepoint to rollback to
-
releaseSavepoint
Description copied from interface:TransactionHandler
Release a previously created savepoint.- Specified by:
releaseSavepoint
in 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:TransactionHandler
Run a transaction.- Specified by:
inTransaction
in 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:TransactionHandler
Run a transaction.- Specified by:
inTransaction
in 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:
-
binding
-
reset
-