diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java index d9b68de09bc1..116898d11c0a 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java @@ -99,7 +99,7 @@ public ResultSetWrappingSqlRowSet(ResultSet resultSet) throws InvalidResultSetAc ResultSetMetaData rsmd = resultSet.getMetaData(); if (rsmd != null) { int columnCount = rsmd.getColumnCount(); - this.columnLabelMap = CollectionUtils.newHashMap(columnCount); + this.columnLabelMap = CollectionUtils.newHashMap(columnCount * 2); for (int i = 1; i <= columnCount; i++) { String key = rsmd.getColumnLabel(i); // Make sure to preserve first matching column for any given name, @@ -107,6 +107,15 @@ public ResultSetWrappingSqlRowSet(ResultSet resultSet) throws InvalidResultSetAc if (!this.columnLabelMap.containsKey(key)) { this.columnLabelMap.put(key, i); } + // Also support column names prefixed with table name + // as in {table_name}.{column.name}. + String table = rsmd.getTableName(i); + if (table != null && !table.isEmpty()) { + key = table + "." + rsmd.getColumnName(i); + if (!this.columnLabelMap.containsKey(key)) { + this.columnLabelMap.put(key, i); + } + } } } else {