/** * INTERNAL: * Get the value from the object for this mapping. */ @Override public Object valueFromObject(Object object, DatabaseField field, AbstractSession session) throws DescriptorException { return getFieldValue(getAttributeValueFromObject(object), session); }
/** * INTERNAL: * Get the value from the object for this mapping. */ @Override public Object valueFromObject(Object object, DatabaseField field, AbstractSession session) throws DescriptorException { return getFieldValue(getAttributeValueFromObject(object), session); }
/** * INTERNAL: * Get the value from the object for this mapping. */ public Object valueFromObject(Object object, DatabaseField field, AbstractSession session) throws DescriptorException { return getFieldValue(getAttributeValueFromObject(object), session); }
/** * INTERNAL: * Compare the attribute values. */ protected boolean compareObjectValues(Object firstValue, Object secondValue, AbstractSession session) { // PERF: Check identity before conversion. if (firstValue == secondValue) { return true; } // CR2114 - following two lines modified; getFieldValue() needs class as an argument firstValue = getFieldValue(firstValue, session); secondValue = getFieldValue(secondValue, session); // PERF: Check identity/nulls before special type comparison. if (firstValue == secondValue) { return true; } if ((firstValue == null) || (secondValue == null)) { return false; } // PERF: Check equals first, as normally no change. boolean equal = firstValue.equals(secondValue); if (equal) { return true; } return Helper.comparePotentialArrays(firstValue, secondValue); }
firstValue = getFieldValue(firstValue, session); secondValue = getFieldValue(secondValue, session);
firstValue = getFieldValue(firstValue, session); secondValue = getFieldValue(secondValue, session);
/** * 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 (this.isReadOnly) { return; } Object attributeValue = getAttributeValueFromObject(object); Object fieldValue = getFieldValue(attributeValue, session); writeValueIntoRow(row, this.field, fieldValue); }
/** * INTERNAL: * Clone the actual value represented by this mapping. Do set the cloned value into the object. * @param attributeValue * @param session * @return */ protected Object buildCloneValue(Object attributeValue, AbstractSession session) { Object newAttributeValue = attributeValue; if (isMutable() && attributeValue != null) { // EL Bug 252047 - Mutable attributes are not cloned when isMutable is enabled on a Direct Mapping if (attributeValue instanceof byte[]) { int length = ((byte[]) attributeValue).length; byte[] arrayCopy = new byte[length]; System.arraycopy(attributeValue, 0, arrayCopy, 0, length); newAttributeValue = arrayCopy; } else if (attributeValue instanceof Date) { newAttributeValue = ((Date)attributeValue).clone(); } else if (attributeValue instanceof Calendar) { newAttributeValue = ((Calendar)attributeValue).clone(); } else { newAttributeValue = getAttributeValue(getFieldValue(attributeValue, session), session); } } return newAttributeValue; }
newAttributeValue = ((Calendar)attributeValue).clone(); } else { newAttributeValue = getObjectValue(getFieldValue(attributeValue, session), session);
newAttributeValue = ((Calendar)attributeValue).clone(); } else { newAttributeValue = getObjectValue(getFieldValue(attributeValue, session), session);
} else { if (mapping.isDirectToFieldMapping()) { fieldValue = ((AbstractDirectMapping)mapping).getFieldValue(objectValue, session); } else if (mapping.isDirectCollectionMapping()) { fieldValue = ((DirectCollectionMapping)mapping).getFieldValue(objectValue, session);
public boolean marshalSingleValue(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, Object objectValue, AbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext) { Object fieldValue = directMapping.getFieldValue(objectValue, session); if ((null == fieldValue) || (null == namespaceResolver)) { return false;
/** * INTERNAL: * Get a value from the object and set that in the respective field of the row. * Validation preventing primary key updates is implemented here. */ public void writeFromObjectIntoRowWithChangeRecord(ChangeRecord changeRecord, AbstractRecord row, AbstractSession session) { if (this.isReadOnly) { return; } if (this.isPrimaryKeyMapping && !changeRecord.getOwner().isNew()) { throw ValidationException.primaryKeyUpdateDisallowed(changeRecord.getOwner().getClassName(), changeRecord.getAttribute()); } Object attributeValue = ((DirectToFieldChangeRecord)changeRecord).getNewValue(); Object fieldValue = getFieldValue(attributeValue, session); row.add(this.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() || (writeType.equals(WriteType.INSERT) && ! isInsertable()) || (writeType.equals(WriteType.UPDATE) && ! isUpdatable())) { return; } Object attributeValue = getAttributeValueFromObject(object); Object fieldValue = getFieldValue(attributeValue, session); // EL Bug 319759 - if a field is null, then the update call cache should not be used if (fieldValue == null) { row.setNullValueInFields(true); } writeValueIntoRow(row, getField(), 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() || (writeType.equals(WriteType.INSERT) && ! isInsertable()) || (writeType.equals(WriteType.UPDATE) && ! isUpdatable())) { return; } Object attributeValue = getAttributeValueFromObject(object); Object fieldValue = getFieldValue(attributeValue, session); // EL Bug 319759 - if a field is null, then the update call cache should not be used if (fieldValue == null) { row.setNullValueInFields(true); } // cuba begin: we do not want to put NULL values to insert scripts if (fieldValue == null && writeType == WriteType.INSERT) { return; } // cuba end writeValueIntoRow(row, getField(), fieldValue); }
/** * INTERNAL: * Get a value from the object and set that in the respective field of the row. * Validation preventing primary key updates is implemented here. */ @Override public void writeFromObjectIntoRowWithChangeRecord(ChangeRecord changeRecord, AbstractRecord row, AbstractSession session, WriteType writeType) { if (isReadOnly() || (writeType.equals(WriteType.INSERT) && ! isInsertable()) || (writeType.equals(WriteType.UPDATE) && ! isUpdatable())) { return; } if (this.isPrimaryKeyMapping && !changeRecord.getOwner().isNew()) { throw ValidationException.primaryKeyUpdateDisallowed(changeRecord.getOwner().getClassName(), changeRecord.getAttribute()); } Object attributeValue = ((DirectToFieldChangeRecord)changeRecord).getNewValue(); Object fieldValue = getFieldValue(attributeValue, session); // EL Bug 319759 - if a field is null, then the update call cache should not be used if (fieldValue == null) { row.setNullValueInFields(true); } row.add(getField(), fieldValue); }
/** * INTERNAL: * Get a value from the object and set that in the respective field of the row. * Validation preventing primary key updates is implemented here. */ @Override public void writeFromObjectIntoRowWithChangeRecord(ChangeRecord changeRecord, AbstractRecord row, AbstractSession session, WriteType writeType) { if (isReadOnly() || (writeType.equals(WriteType.INSERT) && ! isInsertable()) || (writeType.equals(WriteType.UPDATE) && ! isUpdatable())) { return; } if (this.isPrimaryKeyMapping && !changeRecord.getOwner().isNew()) { throw ValidationException.primaryKeyUpdateDisallowed(changeRecord.getOwner().getClassName(), changeRecord.getAttribute()); } Object attributeValue = ((DirectToFieldChangeRecord)changeRecord).getNewValue(); Object fieldValue = getFieldValue(attributeValue, session); // EL Bug 319759 - if a field is null, then the update call cache should not be used if (fieldValue == null) { row.setNullValueInFields(true); } row.add(getField(), fieldValue); }