Package org.jdbi.v3.core.transaction
Class CMTTransactionHandler
- java.lang.Object
-
- org.jdbi.v3.core.transaction.CMTTransactionHandler
-
- All Implemented Interfaces:
TransactionHandler
public class CMTTransactionHandler extends java.lang.Object implements TransactionHandler
Handler designed to behave properly in a J2EE CMT environment. It will never explicitly begin or commit a transaction, and will throw a runtime exception when rollback is called to force rollback.
-
-
Constructor Summary
Constructors Constructor Description CMTTransactionHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbegin(Handle handle)Called when a transaction is startedvoidcommit(Handle handle)Called when a transaction is committed<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)Called to test if a handle is in a transactionvoidreleaseSavepoint(Handle handle, java.lang.String savepointName)Savepoints are not supported.voidrollback(Handle handle)Called when a transaction is rolled back Will throw a RuntimeException to force transactional rollbackvoidrollbackToSavepoint(Handle handle, java.lang.String name)Savepoints are not supported.voidsavepoint(Handle handle, java.lang.String name)Savepoints are not supported.-
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
-
-
-
-
Method Detail
-
begin
public void begin(Handle handle)
Called when a transaction is started- Specified by:
beginin interfaceTransactionHandler- Parameters:
handle- the handle the transaction is being started on
-
commit
public void commit(Handle handle)
Called when a transaction is committed- Specified by:
commitin interfaceTransactionHandler- Parameters:
handle- the handle the commit is being performed on
-
rollback
public void rollback(Handle handle)
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
-
rollbackToSavepoint
public void rollbackToSavepoint(Handle handle, java.lang.String name)
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
-
isInTransaction
public boolean isInTransaction(Handle handle)
Called to test if a handle is in a 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 name)
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
-
releaseSavepoint
public void releaseSavepoint(Handle handle, java.lang.String savepointName)
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 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)
-
-