users@glassfish.java.net

JPA question

From: Daniel H. Cavalcanti <dhcavalcanti_at_gmail.com>
Date: Fri, 14 Nov 2008 12:14:15 -0500

Hi,

I have a question about JPA. I have an enterprise application that
contains two ejb modules and a web module.

One of the ejb module I call persistence, which contains all my entity
classes and facade classes to manage the data in the database.

The other ejb module I call services, which provides the business API
and implementation. It uses the persistence module to access/handle the
data in the database.

finally, the web module is just the UI implementation of the
application. It also contains a set of servlets that clients that do not
support web services can use to access the database.

Now, here is my problem. One of the servlets takes a username/password,
looks up the user in the database and returns data associated with the
user (user model). This works fine except for the case:

1. Get the user model through the serlvet.
2. Add data to the user model.
3. Get the user model through the servlet does not reflect the changes made.

However, if I connect to the database directly through another tool, I
can issue SQL queries and I see the changes there.

I know I'm missing something in the entity manager to get the most
recent data. The returned data is definitely from a cache, which I don't
want.


I have placed a entityManager.flush() after all calls to the
entityManager that create, update, or delete entities.


thanks,
Daniel.