BeanDescriptor beanDescriptor = new BeanDescriptorBuilder(clazz).getBeanDescriptor();
for (PropertyDescriptor propertyDescriptor : beanDescriptor.getProperties()) {
if (propertyDescriptor.isAnnotationPresent(ManyToMany.class)) {
ManyToMany manyToMany = propertyDescriptor.getAnnotation(ManyToMany.class);
CascadeType[] cascades = manyToMany.cascade();
FetchType fetchType = manyToMany.fetch();
this.checkCascade(collection, manyToMany, beanDescriptor, propertyDescriptor, cascades);
this.checkFetch(collection, manyToMany, beanDescriptor, propertyDescriptor, fetchType);
if (!propertyDescriptor.isAnnotationPresent(JoinTable.class)) {
collection.add("Missing @JoinTable on " + beanDescriptor.getType().getCanonicalName() + "." + propertyDescriptor.getName());
}
}
if (propertyDescriptor.isAnnotationPresent(ManyToOne.class)) {
ManyToOne manyToOne = propertyDescriptor.getAnnotation(ManyToOne.class);
CascadeType[] cascades = manyToOne.cascade();
FetchType fetchType = manyToOne.fetch();
this.checkCascade(collection, manyToOne, beanDescriptor, propertyDescriptor, cascades);
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);