public static Field findField ( Class < ? > clazz , String name ) { Class < ? > entityClass = clazz ; while ( ! Object . class . equals ( entityClass ) && entityClass != null ) { Field [ ] fields = entityClass . getDeclaredFields ( ) ; for ( Field field : fields ) { if ( name . equals ( field . getName ( ) ) ) { return field ; } } entityClass = entityClass . getSuperclass ( ) ; } return null ; }
tries to find a field by a field name