use of io.requery.TransactionException in project requery by requery.
the class ManagedTransaction method begin.
@Override
public Transaction begin() {
if (active()) {
throw new IllegalStateException("transaction already active");
}
transactionListener.beforeBegin(null);
int status = getSynchronizationRegistry().getTransactionStatus();
if (status == Status.STATUS_NO_TRANSACTION) {
try {
getUserTransaction().begin();
initiatedTransaction = true;
} catch (NotSupportedException | SystemException e) {
throw new TransactionException(e);
}
}
getSynchronizationRegistry().registerInterposedSynchronization(this);
try {
connection = connectionProvider.getConnection();
} catch (SQLException e) {
throw new TransactionException(e);
}
uncloseableConnection = new UncloseableConnection(connection);
committed = false;
rolledBack = false;
entities.clear();
transactionListener.afterBegin(null);
return this;
}
use of io.requery.TransactionException in project requery by requery.
the class ConnectionTransaction method commit.
@Override
public void commit() {
try {
transactionListener.beforeCommit(entities.types());
if (supportsTransaction) {
connection.commit();
committed = true;
}
transactionListener.afterCommit(entities.types());
entities.clear();
} catch (SQLException e) {
throw new TransactionException(e);
} finally {
resetConnection();
close();
}
}
Aggregations