All,

I'm trying to create the HQL to load an entity and all its children,
ordering both and I'm struggling a little. It may be possible using
Critera but I must admit I find those a little hard to understand so
tend to use HQL.

I have a self referencing table with data like the following

ID,Name,Parent,Sequence
1, Fred, null, 0
2, Jack, 1, 0
3, Jill, 1, 1
4, Mary, 1, 2
6, Bill, null, 1
7, Murray, 6, 0
8, Katy, 6, 1
9, New York, 8, 0
10, London, 8, 1
11, Boston, 8, 2


So Fred and Bill are both roots but are sorted in sequence (0,1). They
each have their own children also sorted in sequence. As you can see,
the Sequence numbers are sequential within their level parent. Its
possible (i.e. Katy) for the hierarchy to continue down. In my case
though I am only ever going to have a maximum 3 levels (root -> child -
> child).

What I'm after is HQL or the criteria query that lets me load a root
for an id, all the children (children A) for that root sorting those
children A by Sequence, then all the children (children B) of children
A sorting those Children B by sequence.

I tried HQL similar to LEFT JOIN FETCH but it loads duplicate roots
and I don't think I could sort Children B with this method.

Any advice please - thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhusers@googlegroups.com
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to