From 3ae6c0f4011efee7c42473bd1807fab05afde089 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 15 May 2014 14:27:44 +0200 Subject: [PATCH] ResultSetWrappingSqlRowSet preserves first matching column per name (as defined in ResultSet's javadoc) Issue: SPR-11786 (cherry picked from commit 0728e32) --- .../jdbc/support/rowset/ResultSetWrappingSqlRowSet.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 69f10432e4a..514ea9b7731 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 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. @@ -99,7 +99,12 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet { int columnCount = rsmd.getColumnCount(); this.columnLabelMap = new HashMap(columnCount); for (int i = 1; i <= columnCount; i++) { - this.columnLabelMap.put(rsmd.getColumnLabel(i), i); + String key = rsmd.getColumnLabel(i); + // Make sure to preserve first matching column for any given name, + // as defined in ResultSet's type-level javadoc (lines 81 to 83). + if (!this.columnLabelMap.containsKey(key)) { + this.columnLabelMap.put(key, i); + } } } else {