- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Closed
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)type: bugA general bugA general bug
Milestone
Description
skzr.org opened SPR-10547 and commented
:(
Method: org.springframework.jdbc.core.BeanPropertyRowMapper.underscoreName(String name)
java doc:
Convert a name in camelCase to an underscored name in lower case. Any upper case letters are converted to lower case with a preceding underscore.
Parameters:
name the string containing original name
Returns:
the converted name
private String underscoreName(String name) {
     StringBuilder result = new StringBuilder();
     if (name != null && name.length() > 0) {
          result.append(name.substring(0, 1).toLowerCase());
          for (int i = 1; i < name.length(); i++) {
               String s = name.substring(i, i + 1);
               if (s.equals(s.toUpperCase())) {
                        result.append("_");
                        result.append(s.toLowerCase());
               }
               else {
                        result.append(s);
               }
          }
     }
     return result.toString();
}
Test:
so, if "s" is a Digit or underscore, it's not work fine.
Ex:
java:
underscoreName("orderTime0") == order_time_0
underscoreName("orderTime1") == order_time_1
db:
column: order_time0, order_time1
but i need order_time0,because 0 is not a upper case.
My Idea:
if (s.equals(s.toUpperCase()))
below it's better!
if (!s.equals(s.toLowerCase()))
Thanks for your help!
Affects: 3.2.2
Issue Links:
- The BeanPropertyRowMapper does not work for field names ending with "numbers" which worked for 3.1 [SPR-16937] #21476 The BeanPropertyRowMapper does not work for field names ending with "numbers" which worked for 3.1
Metadata
Metadata
Assignees
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)type: bugA general bugA general bug