/** * INTERNAL: * Check if the object is invalid and should be refreshed, return true, otherwise return false. * This is used to ensure that no invalid objects are registered. */ public boolean checkInvalidObject(Object object, CacheKey cacheKey, ClassDescriptor descriptor, UnitOfWorkImpl unitOfWork) { if (!unitOfWork.isNestedUnitOfWork() && (cacheKey.getObject() != null)) { CacheInvalidationPolicy cachePolicy = descriptor.getCacheInvalidationPolicy(); // BUG#6671556 refresh invalid objects when accessed in the unit of work. return (cachePolicy.shouldRefreshInvalidObjectsInUnitOfWork() && cachePolicy.isInvalidated(cacheKey)); } return false; }
/** * INTERNAL: * Check if the object is invalid and refresh it. * This is used to ensure that no invalid objects are registered. */ public void checkInvalidObject(Object object, CacheKey cacheKey, ClassDescriptor descriptor) { if (!isNestedUnitOfWork() && (cacheKey.getObject() != null)) { CacheInvalidationPolicy cachePolicy = descriptor.getCacheInvalidationPolicy(); // BUG#6671556 refresh invalid objects when accessed in the unit of work. if (cachePolicy.shouldRefreshInvalidObjectsInUnitOfWork() && cachePolicy.isInvalidated(cacheKey)) { ReadObjectQuery query = new ReadObjectQuery(); query.setReferenceClass(object.getClass()); query.setSelectionKey(cacheKey.getKey()); query.refreshIdentityMapResult(); query.setIsExecutionClone(true); parent.executeQuery(query); } } }