-->
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: Select value object with native SQL
PostPosted: Fri Sep 15, 2006 9:23 am 
Regular
Regular

Joined: Mon Jun 13, 2005 12:21 pm
Posts: 61
Location: Hannover
Hi,

I've already searched the documentation and this forum but didn't find any information. Can anybody tell me, if it's possible to fetch a collection of value objects with native SQL?
I've already tried the following, but withou success (NPE):
Code:
        SQLQuery query = getSession().createSQLQuery(articleQuery.toString());
        query.addEntity("article",Article.class);
        query.addJoin("articleimages","article.articleImages");


Is this possible at all?

Greetings
Joerg

Hibernate version: 3.2

Mapping documents:
Code:

   <class name="Article" table="ARTICLE" >
                ...
      <set name="articleImages" table="ARTIMG" >
         <cache usage="read-only"/>
         <key column="001" />
         <element column="002"
            type="trimmedString">
         </element>
      </set>


Top
 Profile  
 
 Post subject: Use Annotations
PostPosted: Fri Oct 13, 2006 1:08 pm 
Beginner
Beginner

Joined: Thu Jul 06, 2006 11:09 pm
Posts: 25
Use the following class annotations:

@NamedNativeQueries that contains an array of @NamedNativeQuery.

then associate the @NamedNativeQuery using the resultSetMapping parameter with the name of @SqlResultSetMapping class annotation.

Then you may use ScrollableResults from session.getNamedQuery("query").scroll();

This works for me.

_________________
Don't forget to rate.


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.