}
// Turn it 'off' to prevent unwanted events.
policy.dissableEventProcessing(workingClone);
// Set fetch group before building object if a refresh to avoid fetching during building.
FetchGroupManager fetchGroupManager = this.descriptor.getFetchGroupManager();
if (isARefresh && fetchGroupManager != null) {
fetchGroupManager.setObjectFetchGroup(workingClone, query.getExecutionFetchGroup(), unitOfWork);
}
if (descriptor.isProtectedIsolation() && !isIsolated && !query.shouldStoreBypassCache()){
// we are at this point because we have isolated protected entities to the UnitOfWork
// we should ensure that we populate the cache as well.
originalCacheKey = (CacheKey) buildObject(true, query, databaseRow, unitOfWork.getParentIdentityMapSession(descriptor, false, true), primaryKey, descriptor, joinManager);
}
//If we are unable to access the shared cache because of any of the above settings at this point
// the cachekey will be null so the attribute building will not be able to access the shared cache.
if (isARefresh){
//if we need to refresh the UOW then remove the cache key and the clone will be rebuilt not using any of the
//cache. This should be updated to force the buildAttributesIntoWorkingCopyClone to refresh the objects
originalCacheKey = null;
}
// Build/refresh the clone from the row.
buildAttributesIntoWorkingCopyClone(workingClone, originalCacheKey, query, joinManager, databaseRow, unitOfWork, wasAClone);
// Set fetch group after building object if not a refresh to avoid checking fetch during building.
if ((!isARefresh) && fetchGroupManager != null) {
fetchGroupManager.setObjectFetchGroup(workingClone, query.getExecutionFetchGroup(), unitOfWork);
}
Object backupClone = policy.buildBackupClone(workingClone, this, unitOfWork);
// If it was a clone the change listener must be cleared.
if (wasAClone) {