users@glassfish.java.net

Toplink cache and _at_Version annotations

From: <glassfish_at_javadesktop.org>
Date: Mon, 14 Apr 2008 12:07:55 PDT

Hi,

We are currently in the middle of an application conversion resulting in 2 systems being operational, 1 legacy application and 1 j2ee (ejb / jpa). We have annotated all entities with @Version attributes and they work perfectly well.

We currently have disabled caching due to the 2 systems operating on the same database. Tests with cache enabled did surprise me however. Toplink queries the database and returns the objects. It only loads object currently not stored in cache. (As proved by the database profiler).
What surprised me was that although they query for id and all entity attributes they simple ignore them once the id is already loaded. The version attribute is completely ignored as well, while I think it might be a good idea to check that as well to detect any changes on the datastore. I know this is not required by the spec, but might it not be a good idea? To my opinion it enhances the idea of optimistic locking.

I'm not sure if the is the right place to post it, if not, please let me know!

Best regards,
Jeroen Muis
[Message sent by forum member 'jeroen_muis' (jeroen_muis)]

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