EntityTools.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:xcrud 作者:
/**
 * A partir du nom du fieldname, retorune le field
 * @param cl
 * @param fieldName
 * @return
 * @throws FieldNotFound 
 */
private static Field getField(final Class cl, final String fieldName) throws FieldNotFound {
    Class tClass = cl;
    boolean found = false;
    while (!found && (tClass.isAnnotationPresent(Entity.class) || tClass.isAnnotationPresent(MappedSuperclass.class))) {
        try {
            Field field = tClass.getDeclaredField(fieldName);
            if (field.isAnnotationPresent(Lob.class)) {
                throw new FieldNotFound();
            }
            return field;
        } catch (NoSuchFieldException ex) { // on verifie dans la hierarchie aussi
            tClass = tClass.getSuperclass();
        }
    }
    throw new FieldNotFound();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号