-->
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.  [ 4 posts ] 
Author Message
 Post subject: mapping object graph to native query
PostPosted: Fri Apr 28, 2006 11:55 am 
Newbie

Joined: Fri Apr 28, 2006 11:26 am
Posts: 8
Location: Vancouver, WA
I'd like to use hibernate with annotations to run a rather complex native query and map the results to a tree of entities (a root object, with 1...n children, etc) . It looks like @SqlResultSetMapping is the direction I should go (for mapping entities to query results, instead of individual tables), but although it looks easy enough to map the columns in the result set to fields in one or more entities, I don't know how to set up the mapping between the (flattened) result set and the tree-like structure of the entities. Is this possible? I'm new to hibernate and EJB3, so if anyone can point me in the right direction, I would very much appreciate it!

Thanks,
Tim


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 28, 2006 4:23 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Why don't you use HQL?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 28, 2006 4:33 pm 
Newbie

Joined: Fri Apr 28, 2006 11:26 am
Posts: 8
Location: Vancouver, WA
Thanks for the reply, but I'm not sure how HQL gets me around the problem...Essentially, I want to map a tree of objects to the results of a query (rather than individual tables-- the query is rather complex and actually joins together 10 or so tables, and has columns representing results from stored procedures, etc). I don't care whether the query is an HQL or SQL query; I just need to know how to set up the mapping. As I mentioned, I am new to hibernate, so perhaps I'm missing something obvious...

Thanks,
Tim


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 28, 2006 4:43 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
the number of joins is not an issue for HQL (actually usually it's more redeable), the stored proc is a issue though.

In your case I guess you'll have to use an hbm mapping to map your native query. EJB3 is not as flexible as Hibernate here.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.