if (metadata.hasMappingModel()) {
MappingWrapper wrapper = new MappingWrapper(metadata.getMapping());
Iterator i = metadata.getRelationships().iterator();
while (i.hasNext()) {
Relationship r = (Relationship) i.next();
Type parent = rootType.getProperty(
wrapper.getTablePropertyName(r.getPrimaryKeyTable())).getType();
Type child = rootType.getProperty(
wrapper.getTablePropertyName(r.getForeignKeyTable())).getType();
if (parent == null) {
throw new RuntimeException("The parent table ("
+ r.getPrimaryKeyTable() + ") in relationship "
+ r.getName()
+ " was not found in the mapping information.");
} else if (child == null) {
throw new RuntimeException("The child table ("
+ r.getForeignKeyTable() + ") in relationship "
+ r.getName()
+ " was not found in the mapping information.");
}
// ReferenceImpl ref = refMaker.createReference(r, parent, child);
Property parentProp = SDOUtil.createProperty(parent, r.getName(), child);
Property childProp = SDOUtil.createProperty(child, r.getName() + "_opposite", parent);
SDOUtil.setOpposite(parentProp, childProp);
SDOUtil.setOpposite(childProp, parentProp);
SDOUtil.setMany(parentProp, r.isMany());
}