field.getElementMapping().getValueInfo().assertNoSchemaComponents
(field.getElement(), !adapt);
boolean criteria = field.getValueInfo().getUseClassCriteria();
// check for named inverse
FieldMapping mapped = field.getMappedByMapping();
if (mapped != null) {
field.getMappingInfo().assertNoSchemaComponents(field, !adapt);
field.getValueInfo().assertNoSchemaComponents(field, !adapt);
mapped.resolve(mapped.MODE_META | mapped.MODE_MAPPING);
if (!mapped.isMapped() || mapped.isSerialized())
throw new MetaDataException(_loc.get("mapped-by-unmapped",
field, mapped));
if (mapped.getTypeCode() == JavaTypes.PC) {
if (mapped.getJoinDirection() == mapped.JOIN_FORWARD) {
field.setJoinDirection(field.JOIN_INVERSE);
field.setColumns(mapped.getDefiningMapping().
getPrimaryKeyColumns());
} else if (isTypeUnjoinedSubclass(mapped))
throw new MetaDataException(_loc.get
("mapped-inverse-unjoined", field.getName(),
field.getDefiningMapping(), mapped));
field.setForeignKey(mapped.getForeignKey
(field.getDefiningMapping()));
} else if (mapped.getElement().getTypeCode() == JavaTypes.PC) {
if (isTypeUnjoinedSubclass(mapped.getElementMapping()))
throw new MetaDataException(_loc.get
("mapped-inverse-unjoined", field.getName(),
field.getDefiningMapping(), mapped));
// warn the user about making the collection side the owner
Log log = field.getRepository().getLog();
if (log.isInfoEnabled())
log.info(_loc.get("coll-owner", field, mapped));
field.setForeignKey(mapped.getElementMapping().
getForeignKey());
} else
throw new MetaDataException(_loc.get("not-inv-relation",
field, mapped));