List of usage examples for org.hibernate.resource.transaction.spi TransactionStatus COMMITTED
TransactionStatus COMMITTED
To view the source code for org.hibernate.resource.transaction.spi TransactionStatus COMMITTED.
Click Source Link
From source file:org.glite.security.voms.admin.integration.orgdb.tools.OrgDBUtil.java
License:Apache License
public OrgDBUtil(String[] args) throws ParseException, FileNotFoundException, IOException { setupCLParser();//w w w . j a v a 2 s . c om parseCommandLine(args); initializeDatabase(); execute(); Transaction tx = OrgDBSessionFactory.getSessionFactory().getCurrentSession().getTransaction(); TransactionStatus status = tx.getStatus(); if (tx.isActive() && !status.equals(TransactionStatus.COMMITTED) && !status.equals(TransactionStatus.COMMITTING)) { tx.commit(); } }
From source file:org.glite.security.voms.admin.persistence.HibernateFactory.java
License:Apache License
public static void commitTransaction() { Transaction tx = (Transaction) threadTransaction.get(); try {/* w w w.j a va 2 s .c o 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 a v a 2 s . c om*/ 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(); } }