-->
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.  [ 3 posts ] 
Author Message
 Post subject: Returning only first object/table data from theta join
PostPosted: Wed Jan 19, 2005 8:44 am 
Senior
Senior

Joined: Tue Aug 03, 2004 2:11 pm
Posts: 142
Location: Somerset
I'm modelling atree structure in hibernate based on nested set theory (see here http://www.intelligententerprise.com/00 ... o1_1.jhtml).

In the query below, I'm not interested in bringing back the parent object at all, just the children, but as it stands the query will bring back a collection of two element arrays, containing the child as the first array element, and the parent as the second array element (which I am not interested in, I already have it).

How can I get my query to just return TreeNode.children ?

Here's the HQL:


List nodes =
getHibernateTemplate().find(
"FROM TreeNode children, TreeNode parent WHERE children.left BETWEEN parent.left AND parent.right AND parent.identifier = ? and children.type = ? and parent.type = ?",
parameters);

Here's what you would do in SQL (note that only P1 fields are returned, we are not interested in P2, P2 is jsut there to subset the P1 list):

SELECT P1.*
FROM Personnel AS P1, Personnel AS P2
WHERE P1.lft BETWEEN P2.lft AND P2.rgt
AND P2.emp = :myemployee;

_________________
On the information super B road


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 19, 2005 10:52 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Why don't you use a HQL select clause?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 19, 2005 7:10 pm 
Senior
Senior

Joined: Tue Aug 03, 2004 2:11 pm
Posts: 142
Location: Somerset
christian wrote:
Why don't you use a HQL select clause?


Probably because all my brain power was used up in the morning on nesting set theory.

I'll use that, thanks for the suggestion.

_________________
On the information super B road


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