Java Code Examples for org.hibernate.Transaction#wasCommitted()
The following examples show how to use
org.hibernate.Transaction#wasCommitted() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoreDBServiceFacadeImp.java From AIDR with GNU Affero General Public License v3.0 | 6 votes |
@Override public void update(List<E> entityCollection) { Session session = getCurrentSession(); Transaction tx = null; try { tx = session.beginTransaction(); for (E e: entityCollection) { session.saveOrUpdate(e); session.flush(); session.evict(e); } if (!tx.wasCommitted()) tx.commit(); } catch (Exception ex) { logger.error("Update list failed", ex); tx.rollback(); throw new HibernateException("Update list failed"); } }
Example 2
Source File: CoreDBServiceFacadeImp.java From AIDR with GNU Affero General Public License v3.0 | 6 votes |
@Override public void merge(List<E> entityCollection) { Session session = getCurrentSession(); Transaction tx = null; try { tx = session.beginTransaction(); for (E e: entityCollection) { session.merge(e); session.flush(); session.evict(e); } if (!tx.wasCommitted()) tx.commit(); } catch (Exception ex) { logger.error("Merge list failed", ex); tx.rollback(); throw new HibernateException("Merge list failed"); } }
Example 3
Source File: CoreDBServiceFacadeImp.java From AIDR with GNU Affero General Public License v3.0 | 6 votes |
@Override public void save(List<E> entityCollection) { Session session = getCurrentSession(); Transaction tx = null; try { tx = session.beginTransaction(); for (E e: entityCollection) { session.save(e); session.flush(); session.evict(e); } if (!tx.wasCommitted()) tx.commit(); } catch (Exception ex) { logger.error("Save list failed", ex); tx.rollback(); throw new HibernateException("Save list failed"); } }
Example 4
Source File: CoreDBServiceFacadeImp.java From AIDR with GNU Affero General Public License v3.0 | 6 votes |
@Override public void delete(List<E> entityCollection) { Session session = getCurrentSession(); Transaction tx = null; try { tx = session.beginTransaction(); for (E e: entityCollection) { session.buildLockRequest(LockOptions.UPGRADE).lock(e); session.delete(e); session.flush(); session.evict(e); } if (!tx.wasCommitted()) tx.commit(); } catch (Exception ex) { logger.error("Delete list failed", ex); tx.rollback(); throw new HibernateException("Delete list failed"); } }
Example 5
Source File: HibernateSessionService.java From livingdoc-core with GNU General Public License v3.0 | 5 votes |
@Override public void commitTransaction() throws HibernateException { Transaction tx = threadTransaction.get(); threadTransaction.set(null); if (tx != null && ! tx.wasCommitted() && ! tx.wasRolledBack()) { tx.commit(); } }
Example 6
Source File: HibernateSessionService.java From livingdoc-core with GNU General Public License v3.0 | 5 votes |
@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(); } }
Example 7
Source File: HibernateUtil.java From webdsl with Apache License 2.0 | 5 votes |
public void afterTransactionCompletion(Transaction tx) { try { if (tx.wasCommitted()) { afterTransactionCompletionCommitted_.afterTransactionCompletionCommitted_(); } else if (tx.wasRolledBack()) { afterTransactionCompletionRolledBack_.afterTransactionCompletionRolledBack_(); } } catch (Exception e) { ThreadLocalPage.get().exceptionInHibernateInterceptor = e; } }
Example 8
Source File: HibernateUtil.java From document-management-system with GNU General Public License v2.0 | 4 votes |
/** * Commit transaction */ public static void commit(Transaction tx) { if (tx != null && !tx.wasCommitted() && !tx.wasRolledBack()) { tx.commit(); } }
Example 9
Source File: HibernateUtil.java From document-management-system with GNU General Public License v2.0 | 4 votes |
/** * Rollback transaction */ public static void rollback(Transaction tx) { if (tx != null && !tx.wasCommitted() && !tx.wasRolledBack()) { tx.rollback(); } }
Example 10
Source File: HibernateUtil.java From document-management-system with GNU General Public License v2.0 | 4 votes |
/** * Commit transaction */ public static void commit(Transaction tx) { if (tx != null && !tx.wasCommitted() && !tx.wasRolledBack()) { tx.commit(); } }
Example 11
Source File: HibernateUtil.java From document-management-system with GNU General Public License v2.0 | 4 votes |
/** * Rollback transaction */ public static void rollback(Transaction tx) { if (tx != null && !tx.wasCommitted() && !tx.wasRolledBack()) { tx.rollback(); } }