List of usage examples for org.hibernate Transaction markRollbackOnly
default void markRollbackOnly()
From source file:org.glite.security.voms.admin.integration.orgdb.database.OrgDBSessionFactory.java
License:Apache License
public static void commitTransaction() { if (orgDbSessionFactory == null) throw new OrgDBError("Session factory not initialized!"); Session s = orgDbSessionFactory.getSessionFactory().getCurrentSession(); if (!s.isConnected()) { throw new OrgDBError("Session to OrgDB is not connected"); }//from w ww .ja v a 2 s . c om Transaction tx = s.getTransaction(); if (tx == null) { throw new OrgDBError("Cannot commit a null transaction"); } if (!tx.isActive()) { throw new OrgDBError("Cannot commit an inactive transaction"); } try { tx.commit(); } catch (RollbackException e) { log.error("Error committing OrgDB transaction: " + e.getMessage(), e); tx.markRollbackOnly(); rollbackTransaction(); } }