users@glassfish.java.net

Re: Questions on EJB 3.0 and data retrieval.

From: <glassfish_at_javadesktop.org>
Date: Thu, 10 May 2007 12:17:24 PDT

Without methods "int hashCode()" and "boolean equals(Object object)" I still getting old data.
But I found work around:

result = query.getResultList();
  if (result != null) {
    for (Patient item : result) {
      em.refresh(item);
    }
  }

As you can see I'm using refresh method of entity manager.
Using refresh method I'm getting fresh data.
My conclusion is that something wrong with how query getting data from database.
I read book and book said clearly:
"We typically only need to issue a query to get an updated version of the entity from the database".
Keep in mind that I'm getting directly from query new instances of entity if for the period of time new records was added to corresponding table. But even in this case already existing entities do not refresh. This way resulting list from query has outdated entities and fresh entities.
I don't believe this is a feature :)
I'm going to fillout the issue as bug.
[Message sent by forum member 'vladperl' (vladperl)]

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