users@glassfish.java.net

Re: JPA optimistic locking inconsistency

From: <glassfish_at_javadesktop.org>
Date: Wed, 31 Oct 2007 05:55:27 PST

No, both cases are identical in that I make external updates. For some reason in the case of A these external changes are picked up by the cache. It's nothing my application does, at least as far as I can tell.

I think the way it should work is this: before every merge, there should be a check if newer data is in the database. An OptimisticLockException should be thrown AND the cache should be updated or at least cleared. What's the sense of leaving stale data in the cache, when you already know that a newer version is in the database?

In my case A the behavior is exactly like that, even though, as everyone is telling me, internally it works differently. In my case B I can get the same behavior, if I call em.refresh() before every merge, catch the OptimisticLockException and refresh again.

Ulrich
[Message sent by forum member 'ulim' (ulim)]

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