-->
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.  [ 4 posts ] 
Author Message
 Post subject: order by for one to many relationship
PostPosted: Tue Jan 04, 2005 4:10 pm 
Newbie

Joined: Tue Jan 04, 2005 2:46 pm
Posts: 5
Hibernate version:
2.1.7

I have a scenario where B has zero to many relationship with A.

How do I retrieve list of A sorted by a column/field (other than the associated id column) on B?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 04, 2005 6:13 pm 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Code:
session.createQuery("from A where A.B = x order by A.y").list();


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 04, 2005 8:11 pm 
Newbie

Joined: Tue Jan 04, 2005 2:46 pm
Posts: 5
Looks like the sorting you have given in the example is for a column in A. The issue that i am trying to solve requires sorting that needs to be on B's column when retrieving a list of A in a table.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 05, 2005 4:39 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Code:
session.createQuery("from A where A.B = x order by A.B.y").list();


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

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.