This - must match the interface that is extending this one.public interface Transactional<This extends Transactional<This>> extends SqlObject
Use caution with on-demand Transactional instances.
Handle throws TransactionException if closed while a
transaction is open. Since on-demand extensions open and close a handle around each method invocation, calling
begin() on an on-demand Transactional will always leave a transaction open, and thus
always throw this exception.
Users of on-demand Transactional instances should use the inTransaction and useTransaction
methods to execute transactions. It is safe to call other Transactional methods from inside these callbacks.
| Modifier and Type | Method and Description |
|---|---|
default void |
begin()
Begins a transaction.
|
default void |
commit()
Commits the open transaction.
|
default <R,X extends Exception> |
inTransaction(TransactionalCallback<R,This,X> callback)
Executes the given callback within a transaction, returning the value returned by the callback.
|
default <R,X extends Exception> |
inTransaction(TransactionIsolationLevel isolation,
TransactionalCallback<R,This,X> callback)
Executes the given callback within a transaction, returning the value returned by the callback.
|
default void |
releaseSavepoint(String savepointName)
Releases the given savepoint.
|
default void |
rollback()
Rolls back the open transaction.
|
default void |
rollbackToSavepoint(String savepointName)
Rolls back to the given savepoint.
|
default void |
savepoint(String savepointName)
Creates a savepoint with the given name on the transaction.
|
default <X extends Exception> |
useTransaction(TransactionalConsumer<This,X> callback)
Executes the given callback within a transaction.
|
default <X extends Exception> |
useTransaction(TransactionIsolationLevel isolation,
TransactionalConsumer<This,X> callback)
Executes the given callback within a transaction.
|
getHandle, useHandle, withHandledefault void begin()
TransactionException - if called on an on-demand Transactional instance.default void commit()
default void rollback()
default void savepoint(String savepointName)
savepointName - the savepoint name.default void rollbackToSavepoint(String savepointName)
savepointName - the savepoint name.default void releaseSavepoint(String savepointName)
savepointName - the savepoint name.default <R,X extends Exception> R inTransaction(TransactionalCallback<R,This,X> callback) throws X extends Exception
R - method return typeX - exception optionally thrown by the callback.callback - the callback to executeX - any exception thrown by the callback.X extends Exceptiondefault <R,X extends Exception> R inTransaction(TransactionIsolationLevel isolation, TransactionalCallback<R,This,X> callback) throws X extends Exception
R - method return typeX - exception optionally thrown by the callback.isolation - the transaction isolation level.callback - the callback to executeX - any exception thrown by the callback.X extends Exceptiondefault <X extends Exception> void useTransaction(TransactionalConsumer<This,X> callback) throws X extends Exception
X - exception optionally thrown by the callback.callback - the callback to executeX - any exception thrown by the callback.X extends Exceptiondefault <X extends Exception> void useTransaction(TransactionIsolationLevel isolation, TransactionalConsumer<This,X> callback) throws X extends Exception
X - exception optionally thrown by the callback.isolation - the transaction isolation level.callback - the callback to executeX - any exception thrown by the callback.X extends ExceptionCopyright © 2017. All rights reserved.