Skip to content

Commit 8a28645

Browse files
committed
ResultSetWrappingSqlRowSet preserves first matching column per name (as defined in ResultSet's javadoc)
Issue: SPR-11786 (cherry picked from commit 0728e32)
1 parent f94ded8 commit 8a28645

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/support/rowset/ResultSetWrappingSqlRowSet.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -99,7 +99,12 @@ public ResultSetWrappingSqlRowSet(ResultSet resultSet) throws InvalidResultSetAc
9999
int columnCount = rsmd.getColumnCount();
100100
this.columnLabelMap = new HashMap<String, Integer>(columnCount);
101101
for (int i = 1; i <= columnCount; i++) {
102-
this.columnLabelMap.put(rsmd.getColumnLabel(i), i);
102+
String key = rsmd.getColumnLabel(i);
103+
// Make sure to preserve first matching column for any given name,
104+
// as defined in ResultSet's type-level javadoc (lines 81 to 83).
105+
if (!this.columnLabelMap.containsKey(key)) {
106+
this.columnLabelMap.put(key, i);
107+
}
103108
}
104109
}
105110
else {

0 commit comments

Comments
 (0)