public abstract class DbRun extends Object implements Transaction
| Constructor and Description |
|---|
DbRun() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
isRollbackOnError() |
boolean |
isRollbackOnly() |
abstract void |
run(javax.inject.Provider<Database> db)
Implement this method to provide a block of code that uses the provided database
and is transacted.
|
void |
setRollbackOnError(boolean rollbackOnError)
By default the transaction behavior (whether commit() or rollback() is called)
after run() is specified by how this code block is invoked.
|
void |
setRollbackOnException(boolean rollbackOnError)
Deprecated.
use setRollbackOnError() instead
|
void |
setRollbackOnly(boolean rollbackOnly)
If your code inside run() decides for some reason the transaction should rollback
rather than commit, use this method.
|
public abstract void run(javax.inject.Provider<Database> db) throws Exception
If a Throwable is thrown from this method, it will be caught, wrapped in
a DatabaseException (if it is not already one), and then propagated.
Exceptionpublic boolean isRollbackOnError()
isRollbackOnError in interface TransactionThrowable
being thrown from the run(Provider) method - this only
reflects what was requested by calling setRollbackOnError(boolean),
which is not necessarily what will actually happen@Deprecated public void setRollbackOnException(boolean rollbackOnError)
public void setRollbackOnError(boolean rollbackOnError)
DatabaseProvider#transactCommitOnly(DbRun), DatabaseProvider#transactRollbackOnly(DbRun),
and DatabaseProvider#transactRollbackOnError(DbRun). Depending on the
context, you may be able to request different behavior using this method. See
documentation of these transact*() methods for details.setRollbackOnError in interface TransactionrollbackOnError - true to rollback after errors; false to commit or rollback based on
the other settingsDatabaseProvider.transact(DbCodeTx)public boolean isRollbackOnly()
isRollbackOnly in interface TransactionsetRollbackOnly(boolean),
which is not necessarily what will actually happenpublic void setRollbackOnly(boolean rollbackOnly)
If your code inside run() decides for some reason the transaction should rollback rather than commit, use this method.
By default the transaction behavior (whether commit() or rollback() is called)
after run() is specified by how this code block is invoked. For example, see
DatabaseProvider#transactCommitOnly(DbRun), DatabaseProvider#transactRollbackOnly(DbRun),
and DatabaseProvider#transactRollbackOnError(DbRun). Depending on the
context, you may be able to request different behavior using this method. See
documentation of these transact*() methods for details.
setRollbackOnly in interface TransactionrollbackOnly - true to request an unconditional rollback; false to commit or rollback based on
the other settingsDatabaseProvider.transact(DbCodeTx)Copyright © 2016. All rights reserved.