+ "-no-fkcol-name-adapt", context));
if (name == null && targetName == null) {
// 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].getName();
} else if (name != null && targetName == null) {
// 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].getName();
else if (foreign.getColumn(name) != null)
targetName = name;
else
throw new MetaDataException(_loc.get(prefix
+ "-no-fkcol-target-adapt", context, name));