title: Hibernate JPA constraint violation and Transaction already active
body: <p>I have a table with the field 'nom' with the unique constraint and when I test to insert a value of this field that already exists in the table the <strong>org.hibernate.exception.ConstraintViolationException</strong> is thrown. Then after all my persisting I get a <strong>Transaction already active</strong> Exception.</p>
  
  <p>this is my persisting method in a Dao class</p>
  
  <pre><code>public void persist(E entity) throws Exception {
  EntityTransaction tr=entityManager.getTransaction() ;
  tr.begin();
  entityManager.persist(entity);
  tr.commit();
   }
  </code></pre>
  
  <p>and here the code where I catch the exception</p>
  
  <pre><code>try {
  
          rd.persist(r);
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>How Can I solve this Transaction problem  ?</p>