-->
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.  [ 1 post ] 
Author Message
 Post subject: HQL for nested set - failing query
PostPosted: Mon Dec 01, 2008 9:34 am 
Newbie

Joined: Mon Sep 08, 2008 7:51 am
Posts: 7
Hey guys,

Im having a problem with a query im trying to port from SQL to HQL. This HQL query is for a nested set (as per this article: http://dev.mysql.com/tech-resources/art ... -data.html ), however it fails on the sub-query in the from clause:

Code:

SELECT node.name, (COUNT(parent.name) - (sub_tree.depth + 1)) AS depth
FROM Content AS node,
         Content AS parent,
          Content AS sub_parent,
                ( SELECT node.name, (COUNT(parent.name) - 1) AS depth
            FROM Content AS node,
            Content AS parent
            WHERE node.lft BETWEEN parent.lft AND parent.rft
            AND node.name = :leaf
            GROUP BY node.name
            ORDER BY node.lft
            ) AS sub_tree
WHERE node.lft BETWEEN parent.lft AND parent.rft
AND node.lft BETWEEN sub_parent.lft AND sub_parent.rft
AND sub_parent.name = sub_tree.name
GROUP BY node.name
HAVING depth <= 1
ORDER BY node.lft



Im not that familiar with HQL, and the documentation didn't clear up weather or not this is possible.

Any help would be most welcome

Thanks

Tim


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

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.