List of usage examples for org.hibernate.resource.transaction.spi TransactionStatus ROLLING_BACK
TransactionStatus ROLLING_BACK
To view the source code for org.hibernate.resource.transaction.spi TransactionStatus ROLLING_BACK.
Click Source Link
From source file:org.glite.security.voms.admin.persistence.HibernateFactory.java
License:Apache License
public static void commitTransaction() { Transaction tx = (Transaction) threadTransaction.get(); try {/*from w w w . ja v a 2 s. co m*/ if (tx != null && !tx.getStatus().equals(TransactionStatus.COMMITTED) && !tx.getStatus().equals(TransactionStatus.ROLLING_BACK) && !tx.getStatus().equals(TransactionStatus.ROLLED_BACK)) { if (log.isDebugEnabled()) { log.debug("Committing transaction {} for thread {}", tx, Thread.currentThread()); } tx.commit(); } threadTransaction.set(null); } catch (HibernateException ex) { log.error("Error committing hibernate transaction:" + ex.getMessage()); rollbackTransaction(); if (log.isDebugEnabled()) { log.error("Error committing hibernate transaction!", ex); } throw new VOMSDatabaseException(ex.getMessage(), ex); } }
From source file:org.glite.security.voms.admin.persistence.HibernateFactory.java
License:Apache License
public static void rollbackTransaction() { Transaction tx = (Transaction) threadTransaction.get(); TransactionStatus status = tx.getStatus(); log.warn("Rolling back transaction {}", tx); try {//from w w w .j av a2s. com threadTransaction.set(null); if (tx != null && !tx.getStatus().equals(TransactionStatus.COMMITTED) && !tx.getStatus().equals(TransactionStatus.ROLLING_BACK) && !tx.getStatus().equals(TransactionStatus.ROLLED_BACK)) { if (log.isDebugEnabled()) { log.debug("Rolling back transaction {} for thread {}", tx, Thread.currentThread()); } tx.rollback(); } } catch (HibernateException ex) { log.error("Error rolling back hibernate transaction:" + ex.getMessage(), ex); throw new VOMSDatabaseException(ex.getMessage(), ex); } finally { closeSession(); } }