users@glassfish.java.net

Re: exception inserted a deleted entity

From: <glassfish_at_javadesktop.org>
Date: Wed, 06 Jun 2007 07:24:49 PDT

Not sure if you are using the same EM, but section 4.10 of the spec states "In general, bulk update and delete operations should only be performed within a separate transaction or at the beginning of a transaction (before entities have been accessed whose state might be affected by such operations)."

That, and you are also calling em.clear() before you have flushed/commited the transaction - clear causes changes to entities not yet flushed to be lost. The combination of the bulk update followed by clear is probably causing the cache to not be updated even though the delete might have went through to the database.

Clear should only be used sparingly, and not when what you really should be using is a new persistence context. If this is for testing purposes, you might want to rollback the transaction in the reset method.

Best Regards,
Chris
[Message sent by forum member 'chris_delahunt' (chris_delahunt)]

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