mirror of
https://github.com/moparisthebest/JdbcMapper
synced 2024-11-29 04:12:14 -05:00
Improve exception message in RowToObjectMapper and don't look for extra methods with underscores stripped if an exact match is found
This commit is contained in:
parent
2694436119
commit
fe1ab6def8
@ -331,18 +331,19 @@ public class RowToObjectMapper<T> extends RowMapper {
|
|||||||
if (isSetterMethod(m)) {
|
if (isSetterMethod(m)) {
|
||||||
String fieldName = m.getName().substring(3).toUpperCase();
|
String fieldName = m.getName().substring(3).toUpperCase();
|
||||||
//System.out.println("METHOD-fieldName: "+fieldName);
|
//System.out.println("METHOD-fieldName: "+fieldName);
|
||||||
if (!mapFields.containsKey(fieldName)) {
|
AccessibleObject field = mapFields.get(fieldName);
|
||||||
|
if (field == null) {
|
||||||
fieldName = strippedKeys.get(fieldName);
|
fieldName = strippedKeys.get(fieldName);
|
||||||
if (fieldName == null)
|
if (fieldName == null)
|
||||||
continue;
|
continue;
|
||||||
|
field = mapFields.get(fieldName);
|
||||||
}
|
}
|
||||||
// check for overloads
|
// check for overloads
|
||||||
Object field = mapFields.get(fieldName);
|
|
||||||
if (field == null) {
|
if (field == null) {
|
||||||
mapFields.put(fieldName, m);
|
mapFields.put(fieldName, m);
|
||||||
} else {
|
} else {
|
||||||
throw new MapperException("Unable to choose between overloaded methods " + m.getName()
|
throw new MapperException("Unable to choose between overloaded methods '" + m.getName()
|
||||||
+ " on the " + _returnTypeClass.getName() + " class. Mapping is done using "
|
+ "' and '"+((Method)field).getName()+"' for field '"+fieldName+"' on the " + _returnTypeClass.getName() + " class. Mapping is done using "
|
||||||
+ "a case insensitive comparison of SQL ResultSet columns to field "
|
+ "a case insensitive comparison of SQL ResultSet columns to field "
|
||||||
+ "names and public setter methods on the return class. Columns are also "
|
+ "names and public setter methods on the return class. Columns are also "
|
||||||
+ "stripped of '_' and compared if no match is found with them.");
|
+ "stripped of '_' and compared if no match is found with them.");
|
||||||
@ -379,9 +380,9 @@ public class RowToObjectMapper<T> extends RowMapper {
|
|||||||
for (int i = 1; i < _fields.length; i++) {
|
for (int i = 1; i < _fields.length; i++) {
|
||||||
AccessibleObject f = mapFields.get(keys[i]);
|
AccessibleObject f = mapFields.get(keys[i]);
|
||||||
if (f == null) {
|
if (f == null) {
|
||||||
throw new MapperException("Unable to map the SQL column " + keys[i]
|
throw new MapperException("Unable to map the SQL column '" + keys[i]
|
||||||
+ " to a field on the " + _returnTypeClass.getName() +
|
+ "' to a field on the '" + _returnTypeClass.getName() +
|
||||||
" class. Mapping is done using a case insensitive comparision of SQL ResultSet "
|
"' class. Mapping is done using a case insensitive comparison of SQL ResultSet "
|
||||||
+ "columns to field "
|
+ "columns to field "
|
||||||
+ "names and public setter methods on the return class. Columns are also "
|
+ "names and public setter methods on the return class. Columns are also "
|
||||||
+ "stripped of '_' and compared if no match is found with them.");
|
+ "stripped of '_' and compared if no match is found with them.");
|
||||||
|
Loading…
Reference in New Issue
Block a user