INTERNAL:
// If no join columns are specified ...
if (m_joinColumns.isEmpty()) {
if (descriptor.hasCompositePrimaryKey()) {
// Add a default one for each part of the composite primary
// key. Foreign and primary key to have the same name.
for (String primaryKeyField : descriptor.getPrimaryKeyFieldNames()) {
m_joinColumns.add(new MetadataJoinColumn(primaryKeyField));
}
} else {
// Add a default one for the single case, not setting any
// foreign and primary key names. They will default based
// on which accessor is using them.
m_joinColumns.add(new MetadataJoinColumn());
}
} else {
// Need to update any join columns that use a foreign key name
// for the primary key name. E.G. User specifies the renamed id
// field name from a primary key join column as the primary key in
// an inheritance subclass.
for (MetadataJoinColumn joinColumn : m_joinColumns) {
DatabaseField pkField = joinColumn.getPrimaryKeyField();
pkField.setName(descriptor.getPrimaryKeyJoinColumnAssociation(pkField.getName()));
}
}
return m_joinColumns;