Java Code Examples for org.hibernate.resource.transaction.spi.TransactionStatus#FAILED_COMMIT

The following examples show how to use org.hibernate.resource.transaction.spi.TransactionStatus#FAILED_COMMIT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractLogicalConnectionImplementor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void commit() {
	try {
		log.trace( "Preparing to commit transaction via JDBC Connection.commit()" );
		getConnectionForTransactionManagement().commit();
		status = TransactionStatus.COMMITTED;
		log.trace( "Transaction committed via JDBC Connection.commit()" );
	}
	catch( SQLException e ) {
		status = TransactionStatus.FAILED_COMMIT;
		throw new TransactionException( "Unable to commit against JDBC Connection", e );
	}

	afterCompletion();
}
 
Example 2
Source File: TransactionImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void rollback() {
	if ( !isActive() ) {
		if ( jpaCompliance.isJpaTransactionComplianceEnabled() ) {

			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();
	}
}