/** * INTERNAL: * Write fields needed for insert into the template for with null values. */ @Override public void writeInsertFieldsIntoRow(AbstractRecord record, AbstractSession session) { if (isReadOnly()) { return; } for (Object[] pair : this.fieldToTransformers) { DatabaseField field = (DatabaseField)pair[0]; record.put(field, null); } } }
/** * INTERNAL: * Write fields needed for insert into the template for with null values. */ @Override public void writeInsertFieldsIntoRow(AbstractRecord record, AbstractSession session) { if (isReadOnly()) { return; } for (Object[] pair : this.fieldToTransformers) { DatabaseField field = (DatabaseField)pair[0]; record.put(field, null); } } }
/** * INTERNAL: * Write fields needed for insert into the template for with null values. */ public void writeInsertFieldsIntoRow(AbstractRecord record, AbstractSession session) { if (isReadOnly()) { return; } for (Enumeration entry = getFieldToTransformers().elements(); entry.hasMoreElements();) { DatabaseField field = (DatabaseField)((Object[])entry.nextElement())[0]; record.put(field, null); } } }
/** * INTERNAL: * Get a value from the object and set that in the respective field of the row. */ public void writeFromObjectIntoRow(Object object, AbstractRecord row, AbstractSession session) { if (isReadOnly()) { return; } for (Enumeration stream = getFieldToTransformers().elements(); stream.hasMoreElements();) { Object[] next = (Object[])stream.nextElement(); DatabaseField field = (DatabaseField)next[0]; FieldTransformer transformer = (FieldTransformer)next[1]; Object fieldValue = invokeFieldTransformer(field, transformer, object, session); row.put(field, fieldValue); } }
/** * INTERNAL: * Get a value from the object and set that in the respective field of the row. */ @Override public void writeFromObjectIntoRow(Object object, AbstractRecord row, AbstractSession session, WriteType writeType) { if (isReadOnly()) { return; } for (Object[] pair : this.fieldToTransformers) { DatabaseField field = (DatabaseField)pair[0]; FieldTransformer transformer = (FieldTransformer)pair[1]; Object fieldValue = invokeFieldTransformer(field, transformer, object, session); row.put(field, fieldValue); } }
/** * INTERNAL: * Get a value from the object and set that in the respective field of the row. */ @Override public void writeFromObjectIntoRow(Object object, AbstractRecord row, AbstractSession session, WriteType writeType) { if (isReadOnly()) { return; } for (Object[] pair : this.fieldToTransformers) { DatabaseField field = (DatabaseField)pair[0]; FieldTransformer transformer = (FieldTransformer)pair[1]; Object fieldValue = invokeFieldTransformer(field, transformer, object, session); row.put(field, fieldValue); } }
/** * INTERNAL: * Get a value from the object and set that in the respective field of the row. */ public void writeFromObjectIntoRowWithChangeRecord(ChangeRecord changeRecord, AbstractRecord row, AbstractSession session) { if (isReadOnly()) { return; } for (Enumeration stream = getFieldToTransformers().elements(); stream.hasMoreElements();) { Object[] next = (Object[])stream.nextElement(); DatabaseField field = (DatabaseField)next[0]; Object fieldValue = ((TransformationMappingChangeRecord)changeRecord).getRecord().get(field); row.put(field, fieldValue); } }
/** * INTERNAL: * Require for cloning, the part must be cloned. * Ignore the attribute value, go right to the object itself. */ public Object buildCloneForPartObject(Object attributeValue, Object original, CacheKey cacheKey, Object clone, AbstractSession cloningSession, Integer refreshCascade, boolean isExisting, boolean isFromSharedCache) { if (isReadOnly() || !isMutable()) { return attributeValue; } AbstractRecord row = buildPhantomRowFrom(original, cloningSession); return invokeAttributeTransformer(row, clone, cloningSession); }
/** * INTERNAL: * Require for cloning, the part must be cloned. * Ignore the attribute value, go right to the object itself. */ @Override public Object buildCloneForPartObject(Object attributeValue, Object original, CacheKey cacheKey, Object clone, AbstractSession cloningSession, Integer refreshCascade, boolean isExisting, boolean isFromSharedCache) { if (isReadOnly() || !isMutable()) { return attributeValue; } AbstractRecord row = buildPhantomRowFrom(original, cloningSession); return invokeAttributeTransformer(row, clone, cloningSession); }
/** * INTERNAL: * Get a value from the object and set that in the respective field of the row. */ @Override public void writeFromObjectIntoRowWithChangeRecord(ChangeRecord changeRecord, AbstractRecord row, AbstractSession session, WriteType writeType) { if (isReadOnly()) { return; } for (Object[] pair : this.fieldToTransformers) { DatabaseField field = (DatabaseField)pair[0]; Object fieldValue = ((TransformationMappingChangeRecord)changeRecord).getRecord().get(field); row.put(field, fieldValue); } }
/** * INTERNAL: * Get a value from the object and set that in the respective field of the row. */ @Override public void writeFromObjectIntoRowWithChangeRecord(ChangeRecord changeRecord, AbstractRecord row, AbstractSession session, WriteType writeType) { if (isReadOnly()) { return; } for (Object[] pair : this.fieldToTransformers) { DatabaseField field = (DatabaseField)pair[0]; Object fieldValue = ((TransformationMappingChangeRecord)changeRecord).getRecord().get(field); row.put(field, fieldValue); } }
/** * 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); }
if (isReadOnly() || isWriteOnly()) { return null;
/** * 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: * 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: * 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); }
if (isReadOnly() || isWriteOnly()) { return null;
if (isReadOnly() || isWriteOnly()) { return null;
/** * INTERNAL: * Copy of the attribute of the object. * This is NOT used for unit of work but for templatizing an object. */ @Override public void buildCopy(Object copy, Object original, CopyGroup group) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { 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() || !isMutable()) { clonedAttributeValue = getRealAttributeValueFromObject(original, group.getSession()); } else { AbstractRecord row = buildPhantomRowFrom(original, group.getSession()); clonedAttributeValue = invokeAttributeTransformer(row, copy, group.getSession()); } this.indirectionPolicy.reset(copy); setRealAttributeValueInObject(copy, clonedAttributeValue); }
/** * INTERNAL: * Copy of the attribute of the object. * This is NOT used for unit of work but for templatizing an object. */ @Override public void buildCopy(Object copy, Object original, CopyGroup group) { // If mapping is a no-attribute transformation mapping, do nothing if (isWriteOnly()) { 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() || !isMutable()) { clonedAttributeValue = getRealAttributeValueFromObject(original, group.getSession()); } else { AbstractRecord row = buildPhantomRowFrom(original, group.getSession()); clonedAttributeValue = invokeAttributeTransformer(row, copy, group.getSession()); } this.indirectionPolicy.reset(copy); setRealAttributeValueInObject(copy, clonedAttributeValue); }