Search in sources :

Example 1 with RollbackException

use of io.requery.RollbackException in project requery by requery.

the class EntityDataStore method runInTransaction.

@Override
public <V> V runInTransaction(Callable<V> callable, @Nullable TransactionIsolation isolation) {
    Objects.requireNotNull(callable);
    checkClosed();
    Transaction transaction = transactionProvider.get();
    if (transaction == null) {
        throw new TransactionException("no transaction");
    }
    try {
        transaction.begin(isolation);
        V result = callable.call();
        transaction.commit();
        return result;
    } catch (Exception e) {
        transaction.rollback();
        throw new RollbackException(e);
    }
}
Also used : TransactionException(io.requery.TransactionException) Transaction(io.requery.Transaction) RollbackException(io.requery.RollbackException) ReadOnlyException(io.requery.ReadOnlyException) RollbackException(io.requery.RollbackException) SQLException(java.sql.SQLException) TransactionException(io.requery.TransactionException) PersistenceException(io.requery.PersistenceException)

Aggregations

PersistenceException (io.requery.PersistenceException)1 ReadOnlyException (io.requery.ReadOnlyException)1 RollbackException (io.requery.RollbackException)1 Transaction (io.requery.Transaction)1 TransactionException (io.requery.TransactionException)1 SQLException (java.sql.SQLException)1