+ "-no-fkcol-name-adapt", context));
if (DBIdentifier.isNull(name) && DBIdentifier.isNull(targetName)) {
// if no name or target is provided and there's more than one likely
// join possibility, too ambiguous
PrimaryKey pk = foreign.getPrimaryKey();
if (joins.length != 1 || pk == null || pk.getColumns().length != 1)
throw new MetaDataException(_loc.get(prefix
+ "-no-fkcol-name-adapt", context));
// assume target is pk column
targetName = pk.getColumns()[0].getIdentifier();
} else if (!DBIdentifier.isNull(name) && DBIdentifier.isNull(targetName)) {
// if one primary key column use it for target; if multiple joins
// look for a foreign column with same name as local column
PrimaryKey pk = foreign.getPrimaryKey();
if (joins.length == 1 && pk != null && pk.getColumns().length == 1) {
targetName = pk.getColumns()[0].getIdentifier();
}
else if (foreign.getColumn(name) != null) {
targetName = name;
}
else {