title: JPA multiple transactions - commit not handled properly after a rollback
body: <p>I have the following code (simplified for the sake of the question)</p>
  
  <pre><code>EntityManager em = EMF.get().createEntityManager();
  TypedQuery&lt;T&gt; query = em.createQuery...
  for(T result : em.getResultlist()) {
     try {
        em.getTransaction().begin();
  
        // do some stuff, update the T object
  
        em.getTransaction().commit();
     } catch(Exception e) {
        // something has gone wrong, rollback the current transaction
        if(em.getTransaction().isActive()) {
            em.getTransaction().rollback();
        }
     }
  }
  em.close();
  </code></pre>
  
  <p>I am using JPA EclipseLink.</p>
  
  <p>Basically, I want to update a set of tasks, take action and update their statuses. Sometimes the task action fails and I need to revert the change.</p>
  
  <p>This works perfectly fine UNTIL something goes wrong with one of the transactions and the roll back is called. At that point any subsequent transaction commit IS NOT performed, ie the database is not updated.</p>
  
  <p>I read "on rollback all objects managed are detached". I guess this is where the problem is... if correct how could I implement the desired behaviour?</p>
  
  <p>Any help would be vastly appreciated!</p>