if (!(attributeValue instanceof Proxy)) {
boolean isExisting = !cloningSession.isUnitOfWork() || (((UnitOfWorkImpl)cloningSession).isObjectRegistered(clone) && (!((UnitOfWorkImpl)cloningSession).isOriginalNewObject(original)));
return this.getMapping().buildCloneForPartObject(attributeValue, original, null, clone, cloningSession, refreshCascade, isExisting, !buildDirectlyFromRow);
}
ValueHolderInterface newValueHolder;
ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(attributeValue);
ValueHolderInterface oldValueHolder = handler.getValueHolder();
if (!buildDirectlyFromRow && cloningSession.isUnitOfWork() && ((UnitOfWorkImpl)cloningSession).isOriginalNewObject(original)) {
// CR#3156435 Throw a meaningful exception if a serialized/dead value holder is detected.
// This can occur if an existing serialized object is attempt to be registered as new.
if ((oldValueHolder instanceof DatabaseValueHolder)
&& (! ((DatabaseValueHolder) oldValueHolder).isInstantiated())
&& (((DatabaseValueHolder) oldValueHolder).getSession() == null)
&& (! ((DatabaseValueHolder) oldValueHolder).isSerializedRemoteUnitOfWorkValueHolder())) {
throw DescriptorException.attemptToRegisterDeadIndirection(original, getMapping());
}
newValueHolder = new ValueHolder();
newValueHolder.setValue(this.getMapping().buildCloneForPartObject(oldValueHolder.getValue(), original, null, clone, cloningSession, refreshCascade, false, false));
} else {
AbstractRecord row = null;
if (oldValueHolder instanceof DatabaseValueHolder) {
row = ((DatabaseValueHolder)oldValueHolder).getRow();
}