use of org.hibernate.TransactionException in project hibernate-orm by hibernate.
the class TransactionImpl method rollback.
@Override
public void rollback() {
if (jpaCompliance.isJpaTransactionComplianceEnabled()) {
if (!isActive()) {
throw new IllegalStateException("JPA compliance dictates throwing IllegalStateException when #rollback " + "is called on non-active transaction");
}
}
TransactionStatus status = getStatus();
if (status == TransactionStatus.ROLLED_BACK || status == TransactionStatus.NOT_ACTIVE) {
// Allow rollback() calls on completed transactions, just no-op.
LOG.debug("rollback() called on an inactive transaction");
return;
}
if (!status.canRollback()) {
throw new TransactionException("Cannot rollback transaction in current status [" + status.name() + "]");
}
LOG.debug("rolling back");
if (status != TransactionStatus.FAILED_COMMIT || allowFailedCommitToPhysicallyRollback()) {
internalGetTransactionDriverControl().rollback();
}
}
Aggregations