users@glassfish.java.net

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

From: Ryan de Laplante <ryan_at_ijws.com>
Date: Fri, 16 Mar 2007 11:09:51 -0400

I don't think caching should be turned off by default, but I do think
that it is very weird for JPA's internal cache to not be updated when
you make a change using the entity manager, then load the same entity
again using the same entity manager. I would expect the loaded entity
to be up to date.

However if an external program modified the database, I would not expect
the cache to know to update itself. In that case, you would need to
disable caching.


Ryan

glassfish_at_javadesktop.org wrote:
> [i]I'm not an expert on the subject but ran into something similar. I
> found that when other programs changed records in a table that I had
> previously loaded using JPA entities, when I queried the table again the
> fresh data was not loaded. This is because of caching. I ended up
> having to disable caching using a query hint. I don't remember the
> syntax off the top of my head but it was toplink specific.
> [/i]
>
> That's exactly the sort of behaviour that I had suspected all along. But
> never in my wildest visions did I imagine seeing this phenomenon between
> two pieces of code using the same JPA layer [b]in the same process[/b] in
> the same WAR.
>
> I can try the Toplink-specific hints suggested by mayankmishra below,
> but I'm still flummoxed that this isn't default JPA policy.
> [Message sent by forum member 'pohl' (pohl)]
>
> http://forums.java.net/jive/thread.jspa?messageID=208408
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>