Transactor
public interface Transactor extends PooledConnection
A PooledConnection that can perform transactions.
Summary
Nested types |
|---|
public enum Transactor.SQLiteTransactionType extends EnumTransaction types. |
Public methods |
|
|---|---|
abstract boolean |
Returns true if this connection has an active transaction, otherwise false. |
abstract @NonNull R |
<R extends Object> withTransaction(Begins a transaction and runs the |
Inherited methods |
||
|---|---|---|
|
Public methods
inTransaction
abstract boolean inTransaction()
Returns true if this connection has an active transaction, otherwise false.
withTransaction
abstract @NonNull R <R extends Object> withTransaction(
@NonNull Transactor.SQLiteTransactionType type,
@NonNull SuspendFunction1<@NonNull TransactionScope<@NonNull R>, @NonNull R> block
)
Begins a transaction and runs the block within the transaction. If block fails to complete normally i.e., an exception is thrown, or TransactionScope.rollback is invoked then the transaction will be rollback, otherwise it is committed.
If inTransaction returns true and this function is invoked it is the equivalent of starting a nested transaction as if TransactionScope.withNestedTransaction was invoked and the type of the transaction will be ignored since its type will be inherited from the parent transaction.
See also Transaction
| Parameters | |
|---|---|
@NonNull Transactor.SQLiteTransactionType type |
The type of transaction to begin. |
@NonNull SuspendFunction1<@NonNull TransactionScope<@NonNull R>, @NonNull R> block |
The code that will execute within the transaction. |