public void map(boolean adapt) {
field.getValueInfo().assertNoSchemaComponents(field, !adapt);
field.getKeyMapping().getValueInfo().assertNoSchemaComponents
(field.getKey(), !adapt);
ValueMapping elem = field.getElementMapping();
if (elem.getTypeCode() != JavaTypes.PC || elem.isEmbeddedPC())
throw new MetaDataException(_loc.get("not-elem-relation", field));
// check for named inverse
FieldMapping mapped = field.getMappedByMapping();
ValueMappingInfo vinfo = elem.getValueInfo();
boolean criteria = vinfo.getUseClassCriteria();
if (mapped != null) {
if (mapped.getElement().getTypeCode() != JavaTypes.PC)
throw new MetaDataException(_loc.get("not-inv-relation-coll",
field, mapped));
field.getMappingInfo().assertNoSchemaComponents(field, !adapt);
vinfo.assertNoSchemaComponents(elem, !adapt);
mapped.resolve(mapped.MODE_META | mapped.MODE_MAPPING);
if (!mapped.isMapped() || mapped.isSerialized())
throw new MetaDataException(_loc.get("mapped-by-unmapped",
field, mapped));
field.setJoinForeignKey(mapped.getElementMapping().
getForeignKey(field.getDefiningMapping()));
elem.setForeignKey(mapped.getJoinForeignKey());
elem.setUseClassCriteria(criteria);
field.setOrderColumn(mapped.getOrderColumn());
return;
}
field.mapJoin(adapt, true);
if (elem.getTypeMapping().isMapped()) {
ForeignKey fk = vinfo.getTypeJoin(elem, "element", false, adapt);
elem.setForeignKey(fk);
elem.setColumnIO(vinfo.getColumnIO());
} else
RelationStrategies.mapRelationToUnmappedPC(elem, "element", adapt);
elem.setUseClassCriteria(criteria);
elem.mapConstraints("element", adapt);
FieldMappingInfo finfo = field.getMappingInfo();
Column orderCol = finfo.getOrderColumn(field, field.getTable(), adapt);
field.setOrderColumn(orderCol);
field.setOrderColumnIO(finfo.getColumnIO());