EclipseLink - JPA - Entitymanager flush() apparently commits data on mysql
<p>For what I've read, <code>EntityManager.flush()</code> inside a transaction should not commit the data. Especially not, if I'm rolling back my transaction.</p>

<p>Here's a simple chunk of code I'm running for test:</p>

<pre><code>EntityManager em = factory.createEntityManager();
em.getTransaction().begin();
em.persist(myEntity);
em.flush();
em.getTransaction().rollback();
em.close();
</code></pre>

<p>After running this code if I look on MySQL (v.5.x), I see that my entity is persisted, even if I called rollback(). If I remove <code>em.flush()</code> the entity is not persisted. But I need to call it in order to have the id updated. So, what's wrong?</p>