/** * INTERNAL: * Return true if the merge should be bypassed. This would be the case for several reasons, depending on * the kind of merge taking place. */ protected boolean dontDoMerge(Object target, Object source, MergeManager mergeManager) { if (!shouldMergeCascadeReference(mergeManager)) { return true; } if (mergeManager.shouldMergeOriginalIntoWorkingCopy()) { // For reverts we are more concerned about the target than the source. if (!isAttributeValueInstantiated(target)) { return true; } } else { if (mergeManager.shouldRefreshRemoteObject() && shouldMergeCascadeParts(mergeManager) && usesIndirection()) { return true; } else { if (!isAttributeValueInstantiated(source)) { return true; } } } return false; }
/** * Return the coresponding value that should be assigned to the target object for the source object. * This value must be local to the targets object space. */ public Object getTargetVersionOfSourceObject(Object source) { if (shouldMergeWorkingCopyIntoOriginal() || shouldMergeWorkingCopyIntoRemote()) { // Target is in uow parent, or original instance for new object. return ((UnitOfWorkImpl)getSession()).getOriginalVersionOfObject(source); } else if (shouldMergeCloneIntoWorkingCopy() || shouldMergeOriginalIntoWorkingCopy() || shouldMergeCloneWithReferencesIntoWorkingCopy()) { // Target is clone from uow. //make sure we use the register for merge //bug 3584343 return registerObjectForMergeCloneIntoWorkingCopy(source); } else if (shouldRefreshRemoteObject()) { // Target is in session's cache. ClassDescriptor descriptor = getSession().getDescriptor(source); Vector primaryKey = descriptor.getObjectBuilder().extractPrimaryKeyFromObject(source, getSession()); return getSession().getIdentityMapAccessorInstance().getFromIdentityMap(primaryKey, source.getClass(), descriptor); } throw ValidationException.invalidMergePolicy(); }