protected void writeValueIntoRow(AbstractRecord row, DatabaseField field, Object fieldValue) { row.add(getField(), fieldValue); } }
/** * INTERNAL: * Add a field - value pair for LOB field into the context. */ public void addContext(DatabaseField field, Object value) { if (contexts == null) { contexts = new DatabaseRecord(2); } contexts.add(field, value); }
/** * INTERNAL: * This row is built for shallow insert or delete which happens in case of bidirectional relationships. * The foreign keys must be set to null to avoid foreign key constraint violations. */ protected void writeFromObjectIntoRowForShallowOperation(Object object, AbstractRecord databaseRow, AbstractSession session) { if (isReadOnly() || (!isForeignKeyRelationship())) { return; } for (Enumeration fieldsEnum = getForeignKeyFields().elements(); fieldsEnum.hasMoreElements();) { DatabaseField sourceKey = (DatabaseField)fieldsEnum.nextElement(); databaseRow.add(sourceKey, null); } }
/** * INTERNAL: * This row is built for shallow insert which happens in case of bidirectional inserts. * The foreign keys must be set to null to avoid constraints. */ public void writeFromObjectIntoRowForShallowInsertWithChangeRecord(ChangeRecord ChangeRecord, AbstractRecord databaseRow, AbstractSession session) { if (isReadOnly() || (!isForeignKeyRelationship())) { return; } for (Enumeration fieldsEnum = getForeignKeyFields().elements(); fieldsEnum.hasMoreElements();) { DatabaseField sourceKey = (DatabaseField)fieldsEnum.nextElement(); databaseRow.add(sourceKey, null); } }
/** * INTERNAL: * Write fields needed for insert into the template for with null values. */ public void writeInsertFieldsIntoRow(AbstractRecord databaseRow, AbstractSession session) { if (isReadOnly()) { return; } databaseRow.add(getField(), null); } }
/** * INTERNAL: * Write fields needed for insert into the template for with null values. */ public void writeInsertFieldsIntoRow(AbstractRecord databaseRow, AbstractSession session) { if (isReadOnly() || (!isForeignKeyRelationship())) { return; } for (Enumeration fieldsEnum = getForeignKeyFields().elements(); fieldsEnum.hasMoreElements();) { DatabaseField sourceKey = (DatabaseField)fieldsEnum.nextElement(); databaseRow.add(sourceKey, null); } } }
/** * INTERNAL: * Add the field-value pair to the row. */ public Object put(DatabaseField key, Object value) { int index = getFields().indexOf(key); if (index >= 0) { Object oldValue = getValues().elementAt(index); replaceAt(value, index); return oldValue; } else { add(key, value); } return null; }
/** * INTERNAL: * A subclass should implement this method if it wants different behaviour. * Write the foreign key values from the attribute to the row. */ public void writeFromAttributeIntoRow(Object attribute, AbstractRecord row, AbstractSession session) { for (Enumeration fieldsEnum = getForeignKeyFields().elements(); fieldsEnum.hasMoreElements();) { DatabaseField sourceKey = (DatabaseField) fieldsEnum.nextElement(); DatabaseField targetKey = (DatabaseField) getSourceToTargetKeyFields().get(sourceKey); Object referenceValue = null; // If privately owned part is null then method cannot be invoked. if (attribute != null) { referenceValue = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(attribute, targetKey, session); } row.add(sourceKey, referenceValue); } }
/** * INTERNAL: * Write fields needed for insert into the template for with null values. */ public void writeInsertFieldsIntoRow(AbstractRecord databaseRow, AbstractSession session) { if (isReadOnly()) { return; } AbstractRecord targetRow = buildTemplateInsertRow(session); for (Enumeration keyEnum = targetRow.keys(); keyEnum.hasMoreElements();) { DatabaseField field = (DatabaseField)keyEnum.nextElement(); Object value = targetRow.get(field); //CR-3286097 - Should use add not put, to avoid linear search. databaseRow.add(field, value); } }
/** * INTERNAL: * Get the attribute value from the object and add the appropriate * values to the specified database row. */ public void writeFromObjectIntoRowWithChangeRecord(ChangeRecord changeRecord, AbstractRecord databaseRow, AbstractSession session) throws DescriptorException { if (isReadOnly()) { return; } AbstractRecord targetRow = buildRowFromAggregateWithChangeRecord(changeRecord, (ObjectChangeSet)((AggregateChangeRecord)changeRecord).getChangedObject(), session); for (Enumeration stream = targetRow.keys(); stream.hasMoreElements();) { DatabaseField field = (DatabaseField)stream.nextElement(); Object value = targetRow.get(field); databaseRow.add(field, value); } }
/** * INTERNAL: * Get the attribute value from the object and add the appropriate * values to the specified database row. */ public void writeFromObjectIntoRow(Object object, AbstractRecord databaseRow, AbstractSession session) throws DescriptorException { if (isReadOnly()) { return; } AbstractRecord targetRow = buildRowFromAggregate(object, getAttributeValueFromObject(object), session); for (Enumeration stream = targetRow.keys(); stream.hasMoreElements();) { DatabaseField field = (DatabaseField)stream.nextElement(); Object value = targetRow.get(field); databaseRow.add(field, value); } }
/** * INTERNAL: * Get the attribute value from the object and add the changed * values to the specified database row. */ public void writeFromObjectIntoRowForUpdate(WriteObjectQuery query, AbstractRecord databaseRow) throws DescriptorException { if (isReadOnly()) { return; } AbstractRecord targetRow = buildRowFromAggregateForUpdate(query, getAttributeValueFromObject(query.getObject())); for (Enumeration stream = targetRow.keys(); stream.hasMoreElements();) { DatabaseField field = (DatabaseField)stream.nextElement(); Object value = targetRow.get(field); databaseRow.add(field, value); } }
referenceValue = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(referenceObject, targetKey, session); databaseRow.add(sourceKey, referenceValue); DatabaseField sourceKey = (DatabaseField)fieldsEnum.nextElement(); Object referenceValue = referenceRow.get(sourceKey); databaseRow.add(sourceKey, referenceValue);
referenceValue = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(referenceObject, targetKey, session); databaseRow.add(sourceKey, referenceValue); DatabaseField sourceKey = (DatabaseField)fieldsEnum.nextElement(); Object referenceValue = referenceRow.get(sourceKey); databaseRow.add(sourceKey, referenceValue);
thisRow.add(getDirectField(), null); }else{ thisRow.add(getDirectField(), value); for (int counter = count.intValue(); counter > 0; --counter){ thisRow = (AbstractRecord)writeQuery.getTranslationRow().clone(); thisRow.add(getDirectField(), value); thisRow.add(getDirectField(), null); }else{ thisRow.add(getDirectField(), value);
/** * 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 (isReadOnly()) { return; } if (isPrimaryKeyMapping() && !changeRecord.getOwner().isNew()) { throw ValidationException.primaryKeyUpdateDisallowed(changeRecord.getOwner().getClassName(), changeRecord.getAttribute()); } Object attributeValue = ((DirectToFieldChangeRecord)changeRecord).getNewValue(); Object fieldValue = getFieldValue(attributeValue, session); row.add(getField(), fieldValue); }