JPA 2.1 constructor-result - ignores type attribute

Description

According to JPA 2.1 specs: http://download.oracle.com/otndocs/jcp/persistence-2_1-fr-eval-spec/index.html
the orm.xml definiton of constructor-result should allow to specify the column type - through class attribute e.g.:

but the implementation apparently ignoes those values and always tries to map them based on the retrieved result set metadata

This leads to funny situation in which despite that one had provided explicit type mapping, recieves an exception thrown from ConstructorResultColumnProcessor that no matching constructor has been found, so without actually running the query for the first time I can not define the constructor that Hibernate will be able to invoke.

I'm not entirely familar with the Hibernate internalls, but that might seem not entirely portable accross diferent DBMS and JDBC drivers as for instance in one driver the result of COUNT() function can be mapped in int and in another into long. Preferebly the types that were defined in the mapping should take precedence and based on the the proper constructor should be resolved.

As long as I am concerned, the problem lays in implementation of ResultsetMappingSecondPass that never sets the mapped type, and always passes null:

Environment

None

Activity

Show:
Jakub Narloch
August 6, 2014, 9:48 PM

I'm willing to prepare the test case that will help to reproduce this issue.

Gail Badner
August 7, 2014, 4:32 AM

Jakub, please provide a test, preferably as a pull request on https://github.com/hibernate/hibernate-orm; otherwise, attach the test to this issue.
Thanks,
Gail

Gail Badner
August 22, 2014, 6:12 PM

This was fixed by in 4.3. It will be fixed in master by HHH-9279.

Jakub, thanks for letting us know this was already fixed.

Brett Meyer
April 22, 2015, 9:14 PM

Closing rejected issues.

Assignee

Gail Badner

Reporter

Jakub Narloch

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure