users@glassfish.java.net

Toplink cache behavior

From: <glassfish_at_javadesktop.org>
Date: Thu, 26 Jul 2007 09:39:46 PDT

I [i]think[/i] I'm seeing something odd, and want to see if someone with a simpler setup than I have can confirm.

I am on the client. I call a stateless session bean with a (detached, but formerly managed) entity as an argument.

This method simply calls entityManager.merge(), passing the object. The now-merged object is returned from the entityManager, and the stateless session bean method, in turn, returns the merged object back to the client. So far so good.

Back on the client, I grab the merged object's primary key (a simple long).

Next, I call another method on the stateless session bean, passing the primary key. That method simply calls entityManager.find(), passing the primary key. It returns the object so found.

Back on the client, I note that the object that results from the find() call does not contain the changes that should have been persisted via the earlier merge() call!

This suggests to me that perhaps the merge() call is not updating Toplink's cache? And that the find() call is not locating the updated object but is, instead, locating the (stale?) object that was in the cache? Sure enough, when I try to merge() [i]that[/i] object, I get an error saying that the object has been saved (optimistic version problem), which would confirm that I've got a stale object in my hand.

Is anyone aware of any issues related to this behavior? Or should I continue looking for pilot error elsewhere?

Thanks,
Laird
[Message sent by forum member 'ljnelson' (ljnelson)]

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