Optimistic locking and refreshing cache
463120Mar 18 2006 — edited Apr 18 2008My current project involves accessing a legacy database. The legacy app will continue to access and modify the db as always. So we added a "ROW_VERSION" column to every table in the db and for every descriptor:
useVersionLocking("ROW_VERSION", false);
onlyRefreshCacheIfNewerVersion();
disableCacheHits();
alwaysRefreshCache();
It was my understanding that these settings should insure that all reads will check the database to see if the row_version of the object in cache matches the value in the db, and if not the object in cache will be refreshed. This is not the case. The cached object becomes stale after the external update (expected) and is not refreshed from the db on subsequent reads (unexpected). Only calling session.removeFromIdentityMap on the object forces the db read.
Thanks, Frank