// the name of the referenced primary key column.
String defaultFKFieldName = getUpperCaseAttributeName() + "_" + defaultPKFieldName;
// Add the source foreign key fields to the mapping.
for (JoinColumnMetadata joinColumn : processJoinColumns()) {
DatabaseField pkField = joinColumn.getPrimaryKeyField();
pkField.setName(getName(pkField, defaultPKFieldName, MetadataLogger.PK_COLUMN));
pkField.setTable(getReferenceDescriptor().getPrimaryKeyTable());
DatabaseField fkField = joinColumn.getForeignKeyField();
fkField.setName(getName(fkField, defaultFKFieldName, MetadataLogger.FK_COLUMN));
// Set the table name if one is not already set.
if (fkField.getTableName().equals("")) {
fkField.setTable(getDescriptor().getPrimaryTable());
}
// Add a source foreign key to the mapping.
mapping.addForeignKeyField(fkField, pkField);
// If any of the join columns is marked read-only then set the
// mapping to be read only.
if (fkField.isReadOnly()) {
mapping.setIsReadOnly(true);
}
}
}