users@glassfish.java.net

Surprising JPA (Toplink) Behaviour (glassfish v1 UR1)

From: <glassfish_at_javadesktop.org>
Date: Thu, 15 Mar 2007 16:19:29 PST

Today my tenuous grasp on the theory of operation of JPA was shattered. I'd like to describe it on a high level, in hopes that someone can steer me in the right direction.

My team has been building a system that consists of some JAX-WS services, some JSF pages for data-entry, and a shared JPA layer through which the services and the pages read & write data. One team member was responsible for creating the JSF interface, and another for writing the services, and each cooperated on the JPA model layer where appropriate, both working within the same Netbeans project shared through an SVN repository.

The services work well, the data interface works well, and today we had our first integrated test on a real test server -- as opposed to the developer's desktops.

This is the context where I observed some very surprising behaviour: After spending some time entering some data through the JSF pages, I hit one of the web services and noticed that the new (or sometimes changed) rows were not showing up in the results from the services.

Isn't that curious? All this time I had assumed that merely by sharing a common JPA model layer, these two halves of my system would never have entity-freshness problems. Shouldn't the default behaviour be for one piece of JPA-using client code to always be able to see the results of other client code's changes? And vice-versa?

I admit this is my first project with all of these technologies, and there's probably some subtle one-liner that I'm missing. But where? Is it something the JSF managed beans are doing when they write? Is it something the web service is doing incorrectly when it selects? Is it some funky annotation parameter that I'm lacking?

Any help would be appreciated.

Here's an example idiom from the web services layer for selecting...

    private static List runDescriptionQuery(){
        EntityManager em = emf.createEntityManager();
        List queryList = null;
        //Query to get a List of all the available Wines
        try{
            Query query = em.createNamedQuery("WineCategories.findAllWineCategories");
            queryList = query.getResultList();
        }finally{
            em.close();
        }
        return queryList;
    }
[Message sent by forum member 'pohl' (pohl)]

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