users@glassfish.java.net

Re: Forcing commit and em.flush does not seem to do it

From: <glassfish_at_javadesktop.org>
Date: Tue, 04 Mar 2008 20:42:47 PST

No, that wouldn't work.

While all of your work is creating actual DB calls, the problem is that your transaction is not commiting. So all of those objects that you are creating are staying alive, and in the managed state. All flushing does is ensure that they're written to the DB, but it does not release the managed objects.

You might trying makes calls to em.flush(), then followed by a call em.clear(), which is supposed to reset all of the managed entities, and make them unmanaged (and, in theory, available for GC).

If that doesn't work, then you may want to try and break your transaction up in to batches, and commit the transaction at a regular interval.

I'm curious if the em.clear() during a transaction actually works though, so it would be interesting if you tried that and reported back.
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=262339