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:
I'm willing to prepare the test case that will help to reproduce this issue.
Seams that this issue has been already fixed in version 4.3.6:
Although the fix hasn't been yet merged to master:
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.
Closing rejected issues.