This - must match the interface that is extending this one.public interface Transactional<This extends Transactional<This>>
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 |
|---|---|
void |
begin()
Begins a transaction.
|
void |
commit()
Commits the open transaction.
|
<R,X extends Exception> |
inTransaction(TransactionalCallback<R,This,X> callback)
Executes the given callback within a transaction, returning the value returned by the callback.
|
<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.
|
void |
releaseSavepoint(String savepointName)
Releases the given savepoint.
|
void |
rollback()
Rolls back the open transaction.
|
void |
rollbackToSavepoint(String savepointName)
Rolls back to the given savepoint.
|
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.
|
void begin()
TransactionException - if called on an on-demand Transactional instance.void commit()
void rollback()
void savepoint(String savepointName)
savepointName - the savepoint name.void rollbackToSavepoint(String savepointName)
savepointName - the savepoint name.void releaseSavepoint(String savepointName)
savepointName - the savepoint name.<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 Exception<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 © 2016. All rights reserved.