I am using UpdateAllQuery to do bulk update. As a result of executing UpdateAllQuer, EclipseLink shared cache contains stale copy. When we read object again in local session (where UpdateAllQuery was executed ), we get updated objects.
localSession.readObject(someObject) --> gives Updated copy of object. But same does not happen with remote session
remoteSession.readObject(someObject) --> gives stale copy of object.
To get updated copy we need to do
remoteSession.refreshObject(someObject);
Apart from refreshObject(), We can also do remoteSession.getIdentityMapAccessor().isValid()..
but its not possible to use above approach at all places.
So my question is why remoteSession.readObject() does not retrieve updated object in remote session?
I tried to debug.. If we observe
IdentityMapManager.getFromIdentityMap():
if ((cacheKey != null) && (shouldReturnInvalidatedObjects ||
!descriptor.getCacheInvalidationPolicy().isInvalidated(cache Key))) {
Here descriptor.getCacheInvalidationPolicy().isInvalidated(cacheK ey) is returning true in local session (which is correct) & false in remote session.
So it seems invalidationState of cacheKey correctly becomes 'CACHE_KEY_INVALID' in local session (where UpdateAllQuery is executed), but in remote session
cacheKey does not become 'CACHE_KEY_INVALID.
Feel free to file a bug, but I don't know if this can be considered a bug as it seems a draw back when using remote sessions. Remote sessions have their own caches and do not receive notifications that other sessions have invalidated objects. A solution would be to change the remote session's caching options to not cache objects or reduce the size so it is less of an issue.