Skip to content

JDBC findColumn gives wrong result in case of duplicate column labels [SPR-11786] #16408

Closed
@spring-projects-issues

Description

@spring-projects-issues

Teun Hoogendoorn opened SPR-11786 and commented

Consider the following query:

Table foo1 contains 1 column named fooname.
Table foo2 ALSO contains 1 column named fooname.

SELECT * FROM foo1, foo2

(result: fooname, fooname)

findColumn("fooname") should return the FIRST and not the SECOND (LAST) index of fooname.

This bug is introduced in Spring JDBC since the implementation ResultSetWrappingSqlRowSet uses a HashMap.

The code should check for existence of the key in the map and not override the value if the key exists.

See: http://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html
QUOTE: When a getter method is called with a column name and several columns have the same name, the value of the first matching column will be returned.


Affects: 3.2.8, 4.0.4

Referenced from: commits 8a28645, 0728e32, 3ae6c0f

Backported to: 3.2.9

Metadata

Metadata

Assignees

Labels

status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions