title: Serial transactions "thinks" that they are parallel (or my understanging of JTA is broken)
body: <p>I have some transactional code:</p>
  
  <pre class="lang-java prettyprint-override"><code>import org.hibernate.Session;
  void PersistRemovePersist(){ 
  try {
  
      UserTransaction ut = getUt();
      EntityManagerFactory emf = getEmf();
      A = new some.Entity("A");
  
      ut.begin();
      EntityManager em = emf.createEntityManager();
      Session ss = em.unwrap(Session.class);
      saveOrUpdate(A);
      ut.commit();
      em.close();
  
      ut.begin(); //TX1
      EntityManager em = emf.createEntityManager();
      Person a = em.find(Person.class,db.A.getId());
      em.remove(a);
      ut.commit();
      em.close();
  
      ut.begin(); //TX2
      em = emf.createEntityManager();
      em.unwrap(Session.class).saveOrUpdate(A);
      ut.commit(); // &lt;- wrapped StaleObjectStateException
      em.close();
      }catch (Exception e){
          throw new RuntimeException(e);
      }
  }
  </code></pre>
  
  <p>At the code execution I get an exception:</p>
  
  <p><strong>org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) : [some.Entity#1]</strong>  </p>
  
  <p>But why? TX1 and TX2 are serial, not parallel. What am I missing?</p>