Browse Source

Rely on HashSet for uniqueness of mapped names

See gh-32199
pull/32215/head
Juergen Hoeller 2 years ago
parent
commit
341ac76209
  1. 12
      spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java

12
spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java

@ -242,6 +242,9 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
/** /**
* Initialize the mapping meta-data for the given class. * Initialize the mapping meta-data for the given class.
* @param mappedClass the mapped class * @param mappedClass the mapped class
* @see #setMappedClass
* @see BeanUtils#getPropertyDescriptors
* @see #mappedNames(PropertyDescriptor)
*/ */
protected void initialize(Class<T> mappedClass) { protected void initialize(Class<T> mappedClass) {
this.mappedClass = mappedClass; this.mappedClass = mappedClass;
@ -280,17 +283,14 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
* @param pd the property descriptor discovered on initialization * @param pd the property descriptor discovered on initialization
* @return a set of mapped names * @return a set of mapped names
* @since 6.1.4 * @since 6.1.4
* @see #initialize
* @see #lowerCaseName * @see #lowerCaseName
* @see #underscoreName * @see #underscoreName
*/ */
protected Set<String> mappedNames(PropertyDescriptor pd) { protected Set<String> mappedNames(PropertyDescriptor pd) {
Set<String> mappedNames = new HashSet<>(4); Set<String> mappedNames = new HashSet<>(4);
String lowerCaseName = lowerCaseName(pd.getName()); mappedNames.add(lowerCaseName(pd.getName()));
mappedNames.add(lowerCaseName); mappedNames.add(underscoreName(pd.getName()));
String underscoreName = underscoreName(pd.getName());
if (!lowerCaseName.equals(underscoreName)) {
mappedNames.add(underscoreName);
}
return mappedNames; return mappedNames;
} }

Loading…
Cancel
Save