Hibernate version: 3.2.3 (Annotations version 3.3.0)
Name and version of the database you are using: MySql 5
I have a @NamedNativeQuery that looks something like this (simplified for readability):
Code:
@SqlResultSetMappings({
@SqlResultSetMapping(name="doc-id", columns={@ColumnResult(name="id")}),
...
})
@NamedNativeQueries({
@NamedNativeQuery(
name="something",
query="select d.doc_id as id from document d ...",
resultSetMapping="doc-id"
),
...
})
The document.doc_id is a BIGINT mapped as a Long in my document class. When I execute the query, I get back results of type BigInteger, when I'd prefer to have them be type Long.
If I execute the query without using named queries, I can do this:
Code:
List idList = session.createSQLQuery("select doc_id from document doc ...")
.addScalar("doc_id",Hibernate.LONG)
...
.list();
Executing in this way gives me the results I want (Long values). Is there some way I've overlooked to do this same thing with @NamedNativeQuery? There doesn't seem to be any way to specify the type in the @SqlResultSetMapping.
Thanks in advance for your help.