title: JPA - Unable to mark for rollback on PersistenceException
body: <p>Its my first post on this website and I am damn sure that I will get solution to my problem. I am not too good in JPA, so stuck in one issue. Not possible to share the complete code but give you an idea what I am trying to achieve by following example:</p>
  
  <pre><code>underOneMethod(){
  
  Person personObj1 = entityManager.createNamedQuery("Select * from Person where smthing..");
  personObj1.setFirstName("John");
  personObj1 = entityManager.merge(personObj1);
  entityManager.flush();
  
  Person personObj2 = entityManager.createNamedQuery("Select * from Person where smthing..");
  personObj2.setLastName("Cruz");
  personObj2 = entityManager.merge(personObj1);
  entityManager.flush();
  
  } // This code throws me exception. I think it will work if I use entityManager.clear() method after first flush call but still it will be good, of someone can me some idea of what is happening in this case and how can it be resolved. Thanks in advance..!
  </code></pre>