List of usage examples for javax.persistence EntityTransaction isActive
public boolean isActive();
From source file:org.sigmah.server.dao.hibernate.TransactionalInterceptor.java
@Override public Object invoke(MethodInvocation methodInvocation) throws Throwable { EntityManager em = injector.getInstance(EntityManager.class); EntityTransaction tx = em.getTransaction(); //allow joining of transactions if there is an enclosing @Transactional method if (tx.isActive()) { if (log.isDebugEnabled()) { log.debug("[invoke] Transaction already active, just proceed the method."); }//from w ww . j a va 2 s. co m return methodInvocation.proceed(); } tx.begin(); if (log.isDebugEnabled()) { log.debug("[invoke] Begins an entity transaction."); } Object result = attemptInvocation(methodInvocation, tx); // everything was normal so commit the txn (do not move into try block as it interferes // with the advised method's throwing semantics) tx.commit(); if (log.isDebugEnabled()) { log.debug("[invoke] Commits the transaction."); } return result; }
From source file:com.nandhootoo.services.NoteServiceImpl.java
public void merge(Note note) { EntityTransaction tx = null; try {//from w ww . j a va2s . c om entityManager.merge(note); } catch (Exception ex) { if (tx != null && tx.isActive()) tx.rollback(); throw (RuntimeException) ex.getCause(); } }
From source file:com.nandhootoo.services.UserServiceImpl.java
public void merge(User user) { EntityTransaction tx = null; try {/*from w w w .j av a2 s.c om*/ entityManager.merge(user); } catch (Exception ex) { if (tx != null && tx.isActive()) tx.rollback(); throw (RuntimeException) ex.getCause(); } }
From source file:com.nandhootoo.services.IssueServiceImpl.java
public void merge(Issue issue) { EntityTransaction tx = null; try {//from www. ja va 2s.c om entityManager.merge(issue); } catch (Exception ex) { if (tx != null && tx.isActive()) tx.rollback(); throw (RuntimeException) ex.getCause(); } }
From source file:com.nandhootoo.services.NoteServiceImpl.java
public void persist(Note note) { EntityTransaction tx = null; try {//from ww w .ja va2s.c o m entityManager.persist(note); } catch (Exception ex) { if (tx != null && tx.isActive()) tx.rollback(); throw (RuntimeException) ex.getCause(); } }
From source file:com.nandhootoo.services.StatusServiceImpl.java
public void merge(Status status) { EntityTransaction tx = null; try {/*from w w w . j a v a 2s.c o m*/ entityManager.merge(status); } catch (Exception ex) { if (tx != null && tx.isActive()) tx.rollback(); throw (RuntimeException) ex.getCause(); } }
From source file:com.nandhootoo.services.UserServiceImpl.java
public void persist(User user) { EntityTransaction tx = null; try {/* w w w. j ava 2s . co m*/ entityManager.persist(user); } catch (Exception ex) { if (tx != null && tx.isActive()) tx.rollback(); throw (RuntimeException) ex.getCause(); } }
From source file:com.nandhootoo.services.IssueServiceImpl.java
public void persist(Issue issue) { EntityTransaction tx = null; try {/*from w w w.j a v a2 s . c o m*/ entityManager.persist(issue); } catch (Exception ex) { if (tx != null && tx.isActive()) tx.rollback(); throw (RuntimeException) ex.getCause(); } }
From source file:com.nandhootoo.services.ProductServiceImpl.java
public void merge(Product product) { EntityTransaction tx = null; try {/*from w ww . j a v a 2s.c om*/ entityManager.merge(product); } catch (Exception ex) { if (tx != null && tx.isActive()) tx.rollback(); throw (RuntimeException) ex.getCause(); } }
From source file:com.nandhootoo.services.StatusServiceImpl.java
public void persist(Status status) { EntityTransaction tx = null; try {/*from www. j a v a2 s. c o m*/ entityManager.persist(status); } catch (Exception ex) { if (tx != null && tx.isActive()) tx.rollback(); throw (RuntimeException) ex.getCause(); } }