title: Jpa/Hibernate partial rollback issue
body: <p>This is an extract code of my Java Bean where I use Jpa/ Hibernate stack.</p>
  
  <p>I want to manually force the rollback of my transaction by throwing an IllegalArgumentException.</p>
  
  <p>When I control data inside the database I found that containers perform only a partial rollback : 
  - update statement are rollbacked (line 26)
  - insert statement are not rollbacked (line 30)</p>
  
  <p>What is wrong in my code? What must I do in order to rollback the whole transaction?</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>import org.hibernate.FlushMode;
  import org.hibernate.Session;
  import org.hibernate.Transaction;
  
  @Stateless
  public class MyBean {
  
      @PersistenceContext(unitName="mydatasource")
      protected EntityManager em;
  
      public void save() {
  
          Session session = em.unwrap(Session.class);
  
          session.setFlushMode(FlushMode.MANUAL);
  
          Transaction transaction = session.beginTransaction();
          try {
  
              ...
  
              em.merge(anExistingObject);
  
              ...
  
              em.persist(aNewObject);
  
              throw new IllegalArgumentException();
  
              transaction.commit();
  
          } catch (Exception ex) {
  
              transaction.rollback();
  
          } finally {
  
              if (session!=null) {
                  session.flush();
                  session.close();
              }
  
          }
  
      }
  
  }
  </code></pre>