Introduce SimplePropertyRowMapper with flexible constructor/property/field mapping
Includes query(Class) method with value and property mapping support on JdbcClient. JdbcClient's singleColumn/singleValue are declared without a Class parameter now. Closes gh-26594 See gh-30931
This commit is contained in:
@@ -609,6 +609,31 @@ public abstract class ReflectionUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to find a {@link Field field} on the supplied {@link Class} with the
|
||||
* supplied {@code name}. Searches all superclasses up to {@link Object}.
|
||||
* @param clazz the class to introspect
|
||||
* @param name the name of the field (with upper/lower case to be ignored)
|
||||
* @return the corresponding Field object, or {@code null} if not found
|
||||
* @since 6.1
|
||||
*/
|
||||
@Nullable
|
||||
public static Field findFieldIgnoreCase(Class<?> clazz, String name) {
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
Assert.notNull(name, "Name must not be null");
|
||||
Class<?> searchType = clazz;
|
||||
while (Object.class != searchType && searchType != null) {
|
||||
Field[] fields = getDeclaredFields(searchType);
|
||||
for (Field field : fields) {
|
||||
if (name.equalsIgnoreCase(field.getName())) {
|
||||
return field;
|
||||
}
|
||||
}
|
||||
searchType = searchType.getSuperclass();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the field represented by the supplied {@linkplain Field field object} on
|
||||
* the specified {@linkplain Object target object} to the specified {@code value}.
|
||||
|
||||
Reference in New Issue
Block a user