this.checkFetch(collection, manyToOne, beanDescriptor, propertyDescriptor, fetchType);
if (!propertyDescriptor.isAnnotationPresent(JoinColumn.class)) {
collection.add("Missing @JoinColumn on " + beanDescriptor.getType().getCanonicalName() + "." + propertyDescriptor.getName());
} else {
JoinColumn joinColumn = propertyDescriptor.getAnnotation(JoinColumn.class);
if (manyToOne.optional() != joinColumn.nullable()) {
collection.add("Conflict in @ManyToOne(optional) and @JoinColumn(nullable) on " + beanDescriptor.getType().getCanonicalName() + "." + propertyDescriptor.getName());
}
}
}
if (propertyDescriptor.isAnnotationPresent(OneToMany.class)) {
OneToMany oneToMany = propertyDescriptor.getAnnotation(OneToMany.class);
CascadeType[] cascades = oneToMany.cascade();
FetchType fetchType = oneToMany.fetch();
String mappedBy = oneToMany.mappedBy();
this.checkCascade(collection, oneToMany, beanDescriptor, propertyDescriptor, cascades);
this.checkFetch(collection, oneToMany, beanDescriptor, propertyDescriptor, fetchType);
this.checkMappedBy(collection, oneToMany, beanDescriptor, propertyDescriptor, mappedBy);
}
if (propertyDescriptor.isAnnotationPresent(OneToOne.class)) {
OneToOne oneToOne = propertyDescriptor.getAnnotation(OneToOne.class);
CascadeType[] cascades = oneToOne.cascade();
FetchType fetchType = oneToOne.fetch();
String mappedBy = oneToOne.mappedBy();
this.checkCascade(collection, oneToOne, beanDescriptor, propertyDescriptor, cascades);
this.checkFetch(collection, oneToOne, beanDescriptor, propertyDescriptor, fetchType);
if (ConditionUtils.isEmpty(mappedBy)) {
if (!propertyDescriptor.isAnnotationPresent(JoinColumn.class)) {
collection.add("Missing @OneToOne(mappedBy) or @JoinColumn on " + beanDescriptor.getType().getCanonicalName() + "." + propertyDescriptor.getName());
} else {
JoinColumn joinColumn = propertyDescriptor.getAnnotation(JoinColumn.class);
if (oneToOne.optional() != joinColumn.nullable()) {
collection.add("Conflict in @OneToOne(optional) and @JoinColumn(nullable) on " + beanDescriptor.getType().getCanonicalName() + "." + propertyDescriptor.getName());
}
}
}
}