users@glassfish.java.net

Re: Toplink cache and _at_Version annotations

From: <glassfish_at_javadesktop.org>
Date: Tue, 15 Apr 2008 07:30:16 PDT

Hello Jeroen,

TopLink has the onlyRefreshCacheIfNewerVersion api that allows checking the version field to see if there are changes when a refresh is done. This only comes into play though when a query that would cause a refresh is issued - as you've seen, queries that hit the database will not force a refresh. This is an optimzation, since it can be expensive to rebuild/refresh the object when the data is already in the cache.

The onlyRefreshCacheIfNewerVersion api is normally used with the alwaysRefreshCache. The alwaysRefreshCache api will force queries that do hit the database to refresh the cache. This will not force a refresh of registered/managed objects though, to avoid reverting changes made during transactions unintentionally.

You will need to set up a customizer on entities using version fields inorder to call the previously mentioned api on the Entity's descriptors. Please see
  http://www.oracle.com/technology/products/ias/toplink/JPA/essentials/toplink-jpa-extensions.html
for more info.

Best Regards,
Chris
[Message sent by forum member 'chris_delahunt' (chris_delahunt)]

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