RelationshipTranslation translation = new RelationshipTranslation();
if (toField == null) {
JoinTable t = fromField.getAnnotation(JoinTable.class);
JoinColumn c = fromField.getAnnotation(JoinColumn.class);
if (t != null) {
analyzeJoinTable(translation, t);
} else if (c != null) {
//join column represents the column in the target table.
String fromColumn = getColumnName(fromField);
if (fromColumn == null) {
translation.setFromColumns(relationship.getFrom().getTranslation().getPkColumns());
} else {
translation.setFromColumns(new String[] { fromColumn });
}
translation.setToColumns(joinColumnNames(new JoinColumn[] { c }));
} else {
throw new IllegalArgumentException("Default mappings on @OneToMany not implemented.");
}
} else {
String fromColumn = getColumnName(fromField);
if (fromColumn == null) {
translation.setFromColumns(relationship.getFrom().getTranslation().getPkColumns());
} else {
translation.setFromColumns(new String[] { fromColumn });
}
String toColumn = getColumnName(toField);
if (toColumn == null) {
AnnotatedField fullField = getFieldWithFullAnnotations(toField);
JoinColumn joinColumn = fullField.getAnnotation(JoinColumn.class);
if (joinColumn == null) {
translation.setToColumns(relationship.getTo().getTranslation().getPkColumns());
} else {
translation.setToColumns(joinColumnNames(new JoinColumn[] { joinColumn }));
}