JpaEntityMap map = path.firstInstanceOf(JpaEntityMap.class);
JpaEntity target = map.entityForClass(relationship.getTargetEntityName());
if (target == null) {
context.recordConflict(new SimpleValidationFailure(
relationship,
"Invalid relationship target "
+ relationship.getTargetEntityName()));
}
else if (target.getAttributes() == null
|| target.getAttributes().getIds().isEmpty()) {
context.recordConflict(new SimpleValidationFailure(
target,
"Relationship target has no PK defined: "
+ relationship.getTargetEntityName()));
}
else if (target.getAttributes().getIds().size() > 1) {
// TODO: andrus, 4/30/2006 implement this; note that instead of
// checking for "attribute.getJoinColumns().isEmpty()" above,
// we'll have to match individual columns
context.recordConflict(new SimpleValidationFailure(
relationship,
"Defaults for compound FK are not implemented."));
}
else {
JpaId id = target.getAttributes().getIds().iterator().next();