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