Fix regression in BeanPropertyRowMapper.underscoreName(String)

Commit 6316a35 introduced a regression for property names starting with
multiple uppercase letters (such as setEMail(...)).

This commit fixes that regression and includes an additional test to
cover this case.

See gh-27929
Closes gh-27941
This commit is contained in:
Marten Deinum
2022-01-17 07:54:07 +01:00
committed by Sam Brannen
parent c92b9bc7fe
commit 261bc2ad6a
4 changed files with 108 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -273,7 +273,8 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
}
StringBuilder result = new StringBuilder();
for (int i = 0; i < name.length(); i++) {
result.append(Character.toLowerCase(name.charAt(0)));
for (int i = 1; i < name.length(); i++) {
char c = name.charAt(i);
if (Character.isUpperCase(c)) {
result.append('_').append(Character.toLowerCase(c));