/** * INTERNAL: * Clone the attribute from the clone and assign it to the backup. */ @Override public void buildBackupClone(Object clone, Object backup, UnitOfWorkImpl unitOfWork) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { return; } Object attributeValue = getAttributeValueFromObject(clone); Object clonedAttributeValue = this.indirectionPolicy.backupCloneAttribute(attributeValue, clone, backup, unitOfWork); setAttributeValueInObject(backup, clonedAttributeValue); }
/** * INTERNAL: * Clone the attribute from the original and assign it to the clone. */ @Override public void buildClone(Object original, CacheKey cacheKey, Object clone, Integer refreshCascade, AbstractSession cloningSession) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { return; } Object attributeValue = getAttributeValueFromObject(original); Object clonedAttributeValue = this.indirectionPolicy.cloneAttribute(attributeValue, original, cacheKey, clone, refreshCascade, cloningSession, false);// building clone from an original not a row. setAttributeValueInObject(clone, clonedAttributeValue); }
/** * INTERNAL: * Clone the attribute from the original and assign it to the clone. */ @Override public void buildClone(Object original, CacheKey cacheKey, Object clone, Integer refreshCascade, AbstractSession cloningSession) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { return; } Object attributeValue = getAttributeValueFromObject(original); Object clonedAttributeValue = this.indirectionPolicy.cloneAttribute(attributeValue, original, cacheKey, clone, refreshCascade, cloningSession, false);// building clone from an original not a row. setAttributeValueInObject(clone, clonedAttributeValue); }
/** * INTERNAL: * Clone the attribute from the clone and assign it to the backup. */ @Override public void buildBackupClone(Object clone, Object backup, UnitOfWorkImpl unitOfWork) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { return; } Object attributeValue = getAttributeValueFromObject(clone); Object clonedAttributeValue = this.indirectionPolicy.backupCloneAttribute(attributeValue, clone, backup, unitOfWork); setAttributeValueInObject(backup, clonedAttributeValue); }
/** * INTERNAL: * Clone the attribute from the clone and assign it to the backup. */ public void buildBackupClone(Object clone, Object backup, UnitOfWorkImpl unitOfWork) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { return; } Object attributeValue = getAttributeValueFromObject(clone); if (!isMutable()) { setAttributeValueInObject(backup, attributeValue); return; } Object clonedAttributeValue; // If the mapping is read-only, a direct pass through of the value will be performed. // This is done because the method invocation is not possible as the row will be // empty and we have no way to clone the value. // Since the value cannot change anyway we just pass it through. if (isReadOnly()) { clonedAttributeValue = attributeValue; } else { clonedAttributeValue = getIndirectionPolicy().backupCloneAttribute(attributeValue, clone, backup, unitOfWork); } setAttributeValueInObject(backup, clonedAttributeValue); }
/** * INTERNAL: * Clone the attribute from the original and assign it to the clone. */ public void buildClone(Object original, Object clone, UnitOfWorkImpl unitOfWork) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { return; } Object attributeValue = getAttributeValueFromObject(original); Object clonedAttributeValue; // If the mapping is read-only, a direct pass through of the value will be performed. // This is done because the method invocation is not possible as the row will be // empty and we have no way to clone the value. // Since the value cannot change anyway we just pass it through. if (isReadOnly() || !isMutable()) { clonedAttributeValue = attributeValue; } else { clonedAttributeValue = getIndirectionPolicy().cloneAttribute(attributeValue, original, clone, unitOfWork, false);// building clone from an original not a row. } setAttributeValueInObject(clone, clonedAttributeValue); }
/** * INTERNAL: * Extract value from the row and set the attribute to this value in the * working copy clone. * In order to bypass the shared cache when in transaction a UnitOfWork must * be able to populate working copies directly from the row. */ public void buildCloneFromRow(AbstractRecord record, JoinedAttributeManager joinManager, Object clone, ObjectBuildingQuery sourceQuery, UnitOfWorkImpl unitOfWork, AbstractSession executionSession) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { return; } // This will set the value in the clone automatically. Object attributeValue = readFromRowIntoObject(record, joinManager, clone, sourceQuery, executionSession); Object clonedAttributeValue; // If the mapping is read-only, a direct pass through of the value will be performed. // This is done because the method invocation is not possible as the row will be // empty and we have no way to clone the value. // Since the value cannot change anyway we just pass it through. if (isReadOnly() || !isMutable()) { clonedAttributeValue = attributeValue; } else { clonedAttributeValue = getIndirectionPolicy().cloneAttribute(attributeValue, null,// no original clone, unitOfWork, true);// build clone directly from row. } setAttributeValueInObject(clone, clonedAttributeValue); }
/** * INTERNAL: * Extract value from the row and set the attribute to this value in the * working copy clone. * In order to bypass the shared cache when in transaction a UnitOfWork must * be able to populate working copies directly from the row. */ @Override public void buildCloneFromRow(AbstractRecord record, JoinedAttributeManager joinManager, Object clone, CacheKey sharedCacheKey, ObjectBuildingQuery sourceQuery, UnitOfWorkImpl unitOfWork, AbstractSession executionSession) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { return; } // This will set the value in the clone automatically. Object attributeValue = readFromRowIntoObject(record, joinManager, clone, sharedCacheKey, sourceQuery, executionSession, true); if (usesIndirection()) { boolean wasCacheUsed = this.isCacheable && sharedCacheKey != null && this.descriptor.getCachePolicy().isProtectedIsolation() && sharedCacheKey.getObject() != null; //it would be better if wasCacheUsed could be calculated within readFromRowIntoObject but that would require changing the signature of all mappings just for //transformation mapping. if (!wasCacheUsed){ //if the cache was used then the attribute has already been cloned by readFromRowIntoObject attributeValue = this.indirectionPolicy.cloneAttribute(attributeValue, null,// no original null, clone, null, unitOfWork, true);// build clone directly from row. } setAttributeValueInObject(clone, attributeValue); } }
/** * INTERNAL: * Extract value from the row and set the attribute to this value in the * working copy clone. * In order to bypass the shared cache when in transaction a UnitOfWork must * be able to populate working copies directly from the row. */ @Override public void buildCloneFromRow(AbstractRecord record, JoinedAttributeManager joinManager, Object clone, CacheKey sharedCacheKey, ObjectBuildingQuery sourceQuery, UnitOfWorkImpl unitOfWork, AbstractSession executionSession) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { return; } // This will set the value in the clone automatically. Object attributeValue = readFromRowIntoObject(record, joinManager, clone, sharedCacheKey, sourceQuery, executionSession, true); if (usesIndirection()) { boolean wasCacheUsed = this.isCacheable && sharedCacheKey != null && this.descriptor.getCachePolicy().isProtectedIsolation() && sharedCacheKey.getObject() != null; //it would be better if wasCacheUsed could be calculated within readFromRowIntoObject but that would require changing the signature of all mappings just for //transformation mapping. if (!wasCacheUsed){ //if the cache was used then the attribute has already been cloned by readFromRowIntoObject attributeValue = this.indirectionPolicy.cloneAttribute(attributeValue, null,// no original null, clone, null, unitOfWork, true);// build clone directly from row. } setAttributeValueInObject(clone, attributeValue); } }
/** * INTERNAL: * Either create a new change record or update the change record with the new value. * This is used by attribute change tracking. */ @Override public void updateChangeRecord(Object clone, Object newValue, Object oldValue, ObjectChangeSet objectChangeSet, UnitOfWorkImpl uow) { TransformationMappingChangeRecord changeRecord = (TransformationMappingChangeRecord)objectChangeSet.getChangesForAttributeNamed(this.getAttributeName()); Object updatedObject = descriptor.getInstantiationPolicy().buildNewInstance(); this.setAttributeValueInObject(updatedObject, newValue); if (!isWriteOnly()) { if (changeRecord == null) { objectChangeSet.addChange(internalBuildChangeRecord(updatedObject, oldValue, objectChangeSet, uow)); } else { changeRecord.setRow(this.buildPhantomRowFrom(updatedObject, uow)); } } }
/** * INTERNAL: * Either create a new change record or update the change record with the new value. * This is used by attribute change tracking. */ @Override public void updateChangeRecord(Object clone, Object newValue, Object oldValue, ObjectChangeSet objectChangeSet, UnitOfWorkImpl uow) { TransformationMappingChangeRecord changeRecord = (TransformationMappingChangeRecord)objectChangeSet.getChangesForAttributeNamed(this.getAttributeName()); Object updatedObject = descriptor.getInstantiationPolicy().buildNewInstance(); this.setAttributeValueInObject(updatedObject, newValue); if (!isWriteOnly()) { if (changeRecord == null) { objectChangeSet.addChange(internalBuildChangeRecord(updatedObject, oldValue, objectChangeSet, uow)); } else { changeRecord.setRow(this.buildPhantomRowFrom(updatedObject, uow)); } } }
/** * INTERNAL: * Copy of the attribute of the object. * This is NOT used for unit of work but for templatizing an object. */ public void buildCopy(Object copy, Object original, ObjectCopyingPolicy policy) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { return; } Object attributeValue = getAttributeValueFromObject(original); Object clonedAttributeValue; // If the mapping is read-only, a direct pass through of the value will be performed. // This is done because the method invocation is not possible as the row will be // empty and we have no way to clone the value. // Since the value cannot change anyway we just pass it through. if (isReadOnly() || !isMutable()) { clonedAttributeValue = attributeValue; } else { AbstractRecord row = this.buildPhantomRowFrom(original, policy.getSession()); clonedAttributeValue = invokeAttributeTransformer(row, copy, policy.getSession()); } setAttributeValueInObject(copy, clonedAttributeValue); }
setAttributeValueInObject(target, this.indirectionPolicy.getOriginalIndirectionObject(getAttributeValueFromObject(source), targetSession)); return;
setAttributeValueInObject(target, getIndirectionPolicy().getOriginalIndirectionObject(getAttributeValueFromObject(source), mergeManager.getSession())); return;
setAttributeValueInObject(target, this.indirectionPolicy.getOriginalIndirectionObject(getAttributeValueFromObject(source), targetSession)); return;