JdbcTemplate consistently exposes first value of equally named columns

Issue: SPR-16578
This commit is contained in:
Juergen Hoeller
2018-06-11 14:17:03 +02:00
parent b790bd1fd6
commit 7bce7504c7
3 changed files with 36 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -52,13 +52,12 @@ public class ColumnMapRowMapper implements RowMapper<Map<String, Object>> {
public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
Map<String, Object> mapOfColValues = createColumnMap(columnCount);
Map<String, Object> mapOfColumnValues = createColumnMap(columnCount);
for (int i = 1; i <= columnCount; i++) {
String key = getColumnKey(JdbcUtils.lookupColumnName(rsmd, i));
Object obj = getColumnValue(rs, i);
mapOfColValues.put(key, obj);
String column = JdbcUtils.lookupColumnName(rsmd, i);
mapOfColumnValues.putIfAbsent(getColumnKey(column), getColumnValue(rs, i));
}
return mapOfColValues;
return mapOfColumnValues;
}
/**

View File

@@ -253,7 +253,7 @@ public class TableMetaDataContext {
for (Map.Entry<String, ?> entry : inParameters.entrySet()) {
if (column.equalsIgnoreCase(entry.getKey())) {
value = entry.getValue();
// TODO: break;
break;
}
}
}