Skip to content

The BeanPropertyRowMapper does not work for field names ending with "numbers" which worked for 3.1 [SPR-16937] #21476

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions