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;