createNativeQuery seems to return column values by name and not by column index

Description

Sorry, couldn't connect to the Hibernate forum, so I report it in here instead even though I'm not sure certain if it already has been solved.

Executing an SQL query using executeNativeQuery via a JPA entity manager will not return the same values in the columns as if I executed the query in my PostgreSQL prompt. The thing seems to be when I request the same field or table multiple times but using the same name.

In this case the value for column 0 and 1 is always equal to the value of column 2 and 3 (currency and value) when using createNativeQuery but works just fine when executing the SQL manually in psql. The same thing goes for column 25 and 26, the sourceurl columns.

As the problem disapears when I specify unique names using AS in the FROM clauses my guess is that hib iterates the column names and not the column index, i.e. treating the columns in "FROM foo.a, bar.b" as the value from foo.a in both cases.

Environment

None

Activity

Show:
Brett Meyer
December 4, 2013, 8:59 PM

Closing. Feel free to attach a test case, etc. and I'll reopen.

Assignee

Unassigned

Reporter

KarlK

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure