/**
* Find if a OneToOne or OneToMany annotation exits and if it's the case, verify if the fetch is LAZY.
* @param field the field
* @return true if eager, false otherwise
*/
public static boolean isLazy(final Field field) {
final OneToOne oneOne = field.getAnnotation(OneToOne.class);
if (oneOne != null) {
// By Default Eager
return oneOne.fetch().equals(FetchType.LAZY);
}
final ManyToOne manyOne = field.getAnnotation(ManyToOne.class);
if (manyOne != null) {
// By Default Eager
return manyOne.fetch().equals(FetchType.LAZY);
}
final OneToMany oneMany = field.getAnnotation(OneToMany.class);
if (oneMany != null) {
// By Default Lazy
return oneMany.fetch().equals(FetchType.LAZY);
}
final ManyToMany manyMany = field.getAnnotation(ManyToMany.class);
if (manyMany != null) {
// By Default Lazy
return manyMany.fetch().equals(FetchType.LAZY);
}
// Other case, no problem
return true;
}
EntityUtil.java 文件源码
java
阅读 32
收藏 0
点赞 0
评论 0
项目:jbromo
作者:
评论列表
文章目录