users@glassfish.java.net

Re: Surprising JPA (Toplink) Behaviour (glassfish v1 UR1)

From: <glassfish_at_javadesktop.org>
Date: Fri, 16 Mar 2007 07:50:38 PST

I am quite surprised that you are having stale data issues when working with the same JPA layer. Are you sure that all processes are using the same Persistence Unit; the same EntityManagerFactory?
The code you supplied appears to be creating a new EntityManager for every access is this true of your entire system or is an EntityManager being used repeatedly by different requests?
Is it possible that the stale data is already managed within the EntityManager being queried? Changes made in one EntityManager will not automatically appear in entities already managed in another EntityManager.

The only time a refresh should be required is if you have another non JPA application modifying the database (in which case setting non-shared caching through persistence.xml properties may be suggested if the quantity of conflicts is large) or if you wish to refresh an active EntityManager with changes from another EntityManager.
--Gordon
[Message sent by forum member 'gyorke' (gyorke)]

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