When does flush and clear commit?
<p>I'm using JPA EclipseLink 2.0 with Glassfish 3.1.2.2</p>

<p>I want to know if after I call </p>

<pre><code>em.flush() 
em.clear()
</code></pre>

<p>The objects are immediatly commited to the database. My problem is I'm doing so many transactions that I'm getting <code>OutOfMemory</code>. I want to avoid this by flushing the transaction's objects.</p>

<p>After I flush and clear, I can't see any immediate entity commited to the database, I can only see them AFTER the whole process is done, which tells me this isn't actually commiting.</p>

<p>If flush and clear doesn't commit:</p>

<p><strong>1) What does it actually do?</strong></p>

<p><strong>2) Why am I no longer getting OutOfMemory?</strong></p>

<p>Please tell me if I'm right:</p>

<p>The objects that were allocated in my RAM are sent to the database, but changes are not yet commited. This only means I cleared my RAM, the objects are now in the DB server but the transaction is not yet commited.</p>