if (descriptor != null) {
if (mergeManager.getSession().isUnitOfWork()) {
// The unit of works will have a copy or a new instance must be made
if (((UnitOfWorkImpl)mergeManager.getSession()).getLifecycle() == UnitOfWorkImpl.MergePending) {
// We are merging the unit of work into the original.
CacheKey cacheKey = getObjectFromSharedCacheForMerge(mergeManager, targetSession, getId(), descriptor);
if (cacheKey != null){
attributeValue = cacheKey.getObject();
}
if (attributeValue == null){
attributeValue = ((UnitOfWorkImpl)mergeManager.getSession()).getOriginalVersionOfObjectOrNull(getUnitOfWorkClone(), this, descriptor, targetSession);
}
} else {
// We are merging something else within the unit of work.
// this is most likely because we are updating a backup clone and can retrieve
// the working clone as the result.
attributeValue = getUnitOfWorkClone();
}
} else {
// It is not a unitOfWork so we must be merging into a distributed cache.
CacheKey cacheKey = getObjectFromSharedCacheForMerge(mergeManager, targetSession, getId(), descriptor);
this.activeCacheKey = cacheKey;
if (cacheKey != null){
attributeValue = cacheKey.getObject();
}
}
if ((attributeValue == null) && (shouldRead)) {
// If the cache does not have a copy and I should read it from the database