public boolean wasCommitted() { return transaction.wasCommitted(); }
public boolean wasCommitted() throws TransactionException { if (!isBegun() || commitFailed) return false; return transaction.wasCommitted(); }
@Override public void commitTransaction() throws HibernateException { Transaction tx = threadTransaction.get(); threadTransaction.set(null); if (tx != null && ! tx.wasCommitted() && ! tx.wasRolledBack()) { tx.commit(); } }
if (tx.wasCommitted()) { log.info("Creations: " + creates + ", Updates: " + updates);
@Override public void rollbackTransaction() throws HibernateException { Transaction tx = threadTransaction.get(); try { threadTransaction.set(null); if (tx != null && ! tx.wasCommitted() && ! tx.wasRolledBack()) { tx.rollback(); } } finally { closeSession(); } }
/** * Rollback a Hibernate transaction and close the session. * * In case of a problem, this method will log an error but won't propagate any * exception - therefore it may be used safely in a finally{} block. * * @param theHibernateSession * The open session to rollback and close. * @param tx */ protected static void close(Session theHibernateSession, Transaction tx) { try { if ((tx != null) && (tx.isActive() && !tx.wasCommitted())) { tx.rollback(); } } catch (HibernateException he) { getStaticLogger().error("Could not rollback transaction" + tx); } try { if (theHibernateSession != null) { theHibernateSession.close(); } } catch (Exception e) { getStaticLogger().error("Failed to close session " + theHibernateSession, e); } } }
/** * Commit the database transaction. */ public static void rollbackTransaction() throws RepositoryException { Transaction tx = (Transaction) HibernateUtil.threadTransaction.get(); try { HibernateUtil.threadTransaction.set( null ); if ( ( tx != null ) && !tx.wasCommitted() && !tx.wasRolledBack() ) { if ( HibernateUtil.debug ) { HibernateUtil.log.debug( Messages.getInstance().getString( "HIBUTIL.DEBUG_ROLLBACK" ) ); //$NON-NLS-1$ } tx.rollback(); } } catch ( HibernateException ex ) { HibernateUtil.log.error( Messages.getInstance().getErrorString( "HIBUTIL.ERROR_0003_ROLLBACK" ), ex ); //$NON-NLS-1$ throw new RepositoryException( Messages.getInstance().getErrorString( "HIBUTIL.ERROR_0003_ROLLBACK" ), ex ); //$NON-NLS-1$ } finally { HibernateUtil.closeSession(); } }
if ( ( tx != null ) && !tx.wasCommitted() && !tx.wasRolledBack() ) { if ( HibernateUtil.debug ) { HibernateUtil.log.debug( Messages.getInstance().getString( "HIBUTIL.DEBUG_COMMIT_TRANS" ) ); //$NON-NLS-1$