if (beanElementType instanceof BeanValueInfo) {
BeanValueInfo bvi = (BeanValueInfo)beanElementType;
//
OneToManyMapping mapping;
RelationshipType type = oneToManyAnn.type();
if (type == RelationshipType.HIERARCHIC) {
MappedBy mappedBy = propertyInfo.getAnnotation(MappedBy.class);
if (mappedBy != null) {
throw new IllegalStateException();
}
mapping = new OneToManyMapping(bvi.getTypeInfo(), RelationshipType.HIERARCHIC);
} else {
RelatedMappedBy mappedBy = propertyInfo.getAnnotation(RelatedMappedBy.class);
if (mappedBy == null) {
throw new IllegalStateException();
}
mapping = new NamedOneToManyMapping(bvi.getTypeInfo(), mappedBy.value(), type);
}
//
PropertyMapping<OneToManyMapping> oneToManyMapping = new PropertyMapping<OneToManyMapping>(propertyInfo, mapping);
propertyMappings.add(oneToManyMapping);
}
}
}
// Many to one
for (PropertyInfo propertyInfo : info.getProperties(ManyToOne.class)) {
if (propertyInfo instanceof SingleValuedPropertyInfo) {
SingleValuedPropertyInfo svpi = (SingleValuedPropertyInfo)propertyInfo;
ValueInfo vi = svpi.getValue();
if (vi instanceof BeanValueInfo) {
BeanValueInfo bvi = (BeanValueInfo)vi;
//
ManyToOne manyToOneAnn = propertyInfo.getAnnotation(ManyToOne.class);
RelationshipType type = manyToOneAnn.type();
//
if (type == RelationshipType.HIERARCHIC) {
RelationshipMapping hierarchyMapping = new ManyToOneMapping(bvi.getTypeInfo(), RelationshipType.HIERARCHIC);
PropertyMapping<RelationshipMapping> manyToOneMapping = new PropertyMapping<RelationshipMapping>(propertyInfo, hierarchyMapping);