users@glassfish.java.net

Re: exception inserted a deleted entity

From: <glassfish_at_javadesktop.org>
Date: Thu, 17 May 2007 15:02:45 PDT

> I'm not sure what you mean by "refresh your data
> explicitly"
>

I mean calling em.refresh(o);


> I then delete them using a bulk delete operation
> instead of calling em.remove.

Do you a) use JPA bulk delete or b) execute your own JDBC statement, or c) perform SQL update via a CLI or some UI based tool (like SQLPLUS)?

>
> Then in the second pass i perform the same action as
> the first, but this time when it comes to persist the
> records i get an exception that they already exist.
> Which isn't true, they are deleted from the db, but
> obviously still exist in the cache.
>
> I would have thought that em.clear() would have
> removed them from the cache.

Only from the em.cache(), not from the emf (which is a 2nd level cache and it's on by default in TopLink).

At what point of time do you commit the transactions?

thanks,
-marina
[Message sent by forum member 'mvatkina' (mvatkina)]

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