-->
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: Sorting a query with a self-referencing table relationship.
PostPosted: Sun Nov 12, 2006 11:49 pm 
Newbie

Joined: Sun Nov 12, 2006 9:24 pm
Posts: 5
Hi, I have a Process object and table.

This process table represents a tree-structure of Process objects with each one having a reference to the ID of the process' root process.

What i would like to do is list all processes, ordered by the name of the root process.

Something like this.

select p from
HibProcess p,
HibProcess r
where
p.RootProcessID = r.ProcessID
order by
r.Name asc

Unfortunately this does not order correctly at all. When I order by p.Name or any other property on p it works perfectly, however it cannot seem to order by the joined Process' properties.

My RootProcessID property is setup as a many-to-one relationship.

I am using Hibernate 2 I believe.

The Hibernate docs mention that doing these self-referencing queries require multiple select statements and will affect sorting!

How on earth do I get this to work?

Any help would be great. Cheers.


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.