protected Joins join(Joins joins, ClassMapping elem) {
ValueMapping vm = field.getElementMapping();
ForeignKey fk = vm.getForeignKey(elem);
ClassMapping owner = field.getDefiningMapping();
while (fk.getPrimaryKeyTable() != owner.getTable()) {
joins = owner.joinSuperclass(joins, false);
owner = owner.getJoinablePCSuperclassMapping();
if (owner == null)
throw new InternalException();
}
return joins.joinRelation(field.getName(), fk, elem,