-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: can't specify type in @SqlResultSetMapping??
PostPosted: Tue Aug 07, 2007 4:54 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
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.

_________________
nathan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 07, 2007 7:15 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
No it's not possible because JPA does not define the notion of Type

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.