*/
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 = getSourceRelationKeyFields().elementAt(index);
DatabaseField sourceKey = 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 = getTargetRelationKeyFields().elementAt(index);
DatabaseField targetKey = getTargetKeyFields().elementAt(index);
Object targetKeyValue = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(objectAdded, targetKey, query.getSession());
databaseRow.put(targetRelationKey, targetKeyValue);
}
query.getSession().executeQuery(getInsertQuery(), databaseRow);
if ((getHistoryPolicy() != null) && getHistoryPolicy().shouldHandleWrites()) {
getHistoryPolicy().mappingLogicalInsert(getInsertQuery(), databaseRow, query.getSession());