public void begin() throws NotSupportedException, SystemException { log.debug("beginning Hibernate transaction"); assertNotActive(); initSession(); try { getDelegate().begin(); } catch (RuntimeException re) { clearSession(); throw re; } }
public void rollback() throws IllegalStateException, SecurityException, SystemException { log.debug("rolling back Hibernate transaction"); //TODO: translate exceptions that occur into the correct JTA exception assertActive(); Transaction delegate = getDelegate(); clearSession(); rollbackOnly = false; delegate.rollback(); }
public int getStatus() throws SystemException { if (rollbackOnly) { return Status.STATUS_MARKED_ROLLBACK; } else if ( isSessionSet() && getDelegate().isActive() ) { return Status.STATUS_ACTIVE; } else { return Status.STATUS_NO_TRANSACTION; } }
public void setTransactionTimeout(int timeout) throws SystemException { assertActive(); getDelegate().setTimeout(timeout); }
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { log.debug("committing JPA resource-local transaction"); Transaction delegate = getDelegate(); boolean success = false; boolean tempSynchronizationRegistered = synchronizationRegistered; try { if (delegate.isActive()) { if (!rollbackOnly) { if (!tempSynchronizationRegistered) { // should only occur if the user started the transaction // directly through the session getSynchronizations().beforeTransactionCommit(); } delegate.commit(); success = true; } else { rollback(); } } } finally { if (!tempSynchronizationRegistered) { getSynchronizations().afterTransactionCompletion(success); } } }
public void rollback() throws IllegalStateException, SecurityException, SystemException { log.debug("rolling back JPA resource-local transaction"); // TODO: translate exceptions that occur into the correct JTA exception Transaction delegate = getDelegate(); rollbackOnly = false; boolean tempSynchronizationRegistered = synchronizationRegistered; delegate.rollback(); if (!tempSynchronizationRegistered) { getSynchronizations().afterTransactionCompletion(false); } }
public int getStatus() throws SystemException { if (getDelegate().isActive()) { if (rollbackOnly) { return Status.STATUS_MARKED_ROLLBACK; } return Status.STATUS_ACTIVE; } else { return Status.STATUS_NO_TRANSACTION; } }
public void afterCompletion(int status) { boolean success = Status.STATUS_COMMITTED == status; getSynchronizations().afterTransactionCompletion(success); rollbackOnly = false; synchronizationRegistered = false; }
private void assertActive() { if ( !isSessionSet() ) { throw new IllegalStateException("transaction is not active"); } }
@Inject public void init(Synchronizations sync) { setSynchronizations(sync); }
public void setRollbackOnly() throws IllegalStateException, SystemException { log.debug("marking Hibernate transaction for rollback"); assertActive(); rollbackOnly = true; }
@Override public void registerSynchronization(Synchronization sync) { if ( log.isDebugEnabled() ) { log.debug("registering synchronization: " + sync); } assertActive(); getDelegate().registerSynchronization(sync); }
public void begin() throws NotSupportedException, SystemException { log.debug("beginning JPA resource-local transaction"); // TODO: translate exceptions that occur into the correct JTA exception try { getDelegate().begin(); getSynchronizations().afterTransactionBegin(); // use hibernate to manage the synchronizations // that way even if the user commits the transaction // themselves they will still be handled getDelegate().registerSynchronization(this); synchronizationRegistered = true; } catch (RuntimeException re) { throw re; } }
@Override public void registerSynchronization(Synchronization sync) { if (log.isDebugEnabled()) { log.debug("registering synchronization: " + sync); } getDelegate().registerSynchronization(sync); }
public void beforeCompletion() { getSynchronizations().beforeTransactionCommit(); }
private void assertNotActive() throws NotSupportedException { //TODO: translate exceptions that occur into the correct JTA exception if ( isSessionSet() ) { throw new NotSupportedException("transaction is already active"); } }
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { log.debug("committing Hibernate transaction"); //TODO: translate exceptions that occur into the correct JTA exception assertActive(); Transaction delegate = getDelegate(); clearSession(); if (rollbackOnly) { rollbackOnly = false; delegate.rollback(); throw new RollbackException(); } else { delegate.commit(); } }