users@glassfish.java.net

Re: JPA optimistic locking inconsistency

From: <glassfish_at_javadesktop.org>
Date: Fri, 26 Oct 2007 07:14:21 PDT

You are right. Using either refresh before merge or flush after merge will throw the OptimisticLockException immediately. However, in both cases I am still getting stale data. How can I avoid that?

If I understand you correctly, then in my first class I am passing managed objects into the session bean and in the second case the objects are not managed. However, in both cases I am obtaining the objects from the session bean, pass them to the application, where the user modifies them and sends them back to the same session bean, which uses the same EntityManager. The only difference is that one session bean is local and the other remote (however, changing the latter to local had no effect).

So in my eyes in both cases the objects should be managed. Can you think of any tests that I could do in my code to find out where the object in the second class becomes detached?

Thanks a lot for your comments, they are very helpful.

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

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