Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spring-projects-issues opened this issue May 15, 2014 · 2 comments
Assignees
Labels
status: backported type: bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented May 15, 2014

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

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 15, 2014

Juergen Hoeller commented

This fix is available in the latest 3.2.9 and 4.0.5 snapshots now. Please give it a try and let us know whether it works for you...

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented May 15, 2014

Teun Hoogendoorn commented

I've tested with spring-jdbc-3.2.9.BUILD-20140515.132116-16.jar and it is working correctly now.

Thanks for the fast response!

Teun Hoogendoorn

@spring-projects-issues spring-projects-issues added type: bug status: backported labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.0.5 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: backported type: bug
Projects
None yet
Development

No branches or pull requests

2 participants