em.cache()?
Does remote EJB call mean a new EM and a new transaction?
Do you use a native query or a JPQL query to clear the database? If it's the latter, TopLink should mark the affected entities in the EMF (2-nd level global for all EMs in this EMF) cache as invalid. If this doesn't happen, it's a bug. But if you use a native query, it just goes to the database, and the EMF cache is not being updated, so that the next time you try to persist an entity with the id that existed in the previous run, TopLink code will still find it in the EMF cache and report a problem.
Regards,
-marina
[Message sent by forum member 'mvatkina' (mvatkina)]
http://forums.java.net/jive/thread.jspa?messageID=218158