*/
protected void insertAddedObjectEntry(ObjectLevelModifyQuery query, Object objectAdded) throws DatabaseException, OptimisticLockException {
//cr 3819 added the line below to fix the translationtable to ensure that it
// contains the required values
prepareTranslationRow(query.getTranslationRow(), query.getObject(), query.getSession());
AbstractRecord databaseRow = new DatabaseRecord();
// Extract primary key and value from the source.
for (int index = 0; index < getSourceRelationKeyFields().size(); index++) {
DatabaseField sourceRelationKey = (DatabaseField)getSourceRelationKeyFields().elementAt(index);
DatabaseField sourceKey = (DatabaseField)getSourceKeyFields().elementAt(index);
Object sourceKeyValue = query.getTranslationRow().get(sourceKey);
databaseRow.put(sourceRelationKey, sourceKeyValue);
}
// Extract target field and its value. Construct insert statement and execute it
for (int index = 0; index < getTargetRelationKeyFields().size(); index++) {
DatabaseField targetRelationKey = (DatabaseField)getTargetRelationKeyFields().elementAt(index);
DatabaseField targetKey = (DatabaseField)getTargetKeyFields().elementAt(index);
Object targetKeyValue = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(objectAdded, targetKey, query.getSession());
databaseRow.put(targetRelationKey, targetKeyValue);
}
query.getSession().executeQuery(getInsertQuery(), databaseRow);
}