@Override protected void doRollback() { try { if ( isInitiator ) { // failed commits automatically rollback the transaction per JTA spec if ( getLocalStatus() != LocalStatus.FAILED_COMMIT ) { userTransaction.rollback(); LOG.debug( "Rolled back JTA UserTransaction" ); } } else { markRollbackOnly(); } } catch ( Exception e ) { throw new TransactionException( "JTA rollback failed", e ); } }
@Override public boolean isActive() throws HibernateException { if ( getLocalStatus() != LocalStatus.ACTIVE ) { return false; } final int status; try { status = userTransaction.getStatus(); } catch ( SystemException se ) { throw new TransactionException( "Could not determine transaction status: ", se ); } return JtaStatusHelper.isActive( status ); }
@Override public Session getSession(){ session = sessionFactory.getCurrentSession(); if(session == null){ this.session = sessionFactory.openSession(); LOG.debug("Session opened"); } if(session != null && !(session.getTransaction().getLocalStatus().equals(LocalStatus.ACTIVE))){ session.beginTransaction(); LOG.debug("Begining Transaction"); } return this.session; }
@Override public boolean isActive() throws HibernateException { return getLocalStatus() == LocalStatus.ACTIVE; }
/** * Get the current local status of this transaction. * <p/> * This only accounts for the local view of the transaction status. In other words it does not check the status * of the actual underlying transaction. * * @return The current local status. */ public LocalStatus getLocalStatus();