Description
Yash Bajaj opened SPR-16937 and commented
Class name : BeanPropertyRowMapper
Package : package org.springframework.jdbc.core
Issue : The field name that has an "underscore" in it, lets say person_name_1 is a column name in a database which is also present in the result set. Using BeanPropertyRowMapper, you could map the result set to a model class in your codebase. If you are in a JAVA environment, you probably would choose to use personName1 as the choice of the field name. In the Spring-JDBC 3.1 version, the mapper would map them correctly. But, in the Spring-JDBC 4.3 version, the mapper is not able to map it.
Official documentation - https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/jdbc/core/BeanPropertyRowMapper.html
Column values are mapped based on matching the column name as obtained from result set meta-data to public setters for the corresponding properties. The names are matched either directly or by transforming a name separating the parts with underscores to the same name using "camel" case.
Root cause : If you look into the class from the latest version, the initialize method calls the underScoreName() method here - https://github.com/spring-projects/spring-framework/blob/master/spring-jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java#L245
This method's logic maps personName1 to person_name1.
Whereas if you look into the class from the 3.1 version, the initialize method calls the the underScoreName() method here - https://github.com/spring-projects/spring-framework/blob/3.1.x/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/BeanPropertyRowMapper.java#L165
This method's logic maps personName1 to person_name_1.
This is not a backward compatible logic change. The existing systems would break whose column names end with a number.
Could you please look into it or let me know if there's something that I'm missing or this isn't a valid usecase at all?
Affects: 4.3.17, 5.0.6
Issue Links:
- BeanPropertyRowMapper underscoreName [SPR-10547] #15177 BeanPropertyRowMapper underscoreName
- BeanPropertyRowMapper should always call toLowerCase with US encoding [SPR-13216] #17807 BeanPropertyRowMapper should always call toLowerCase with US encoding