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.  [ 2 posts ] 
Author Message
 Post subject: Ordering on related object ?
PostPosted: Fri Jun 06, 2008 5:40 am 
Newbie

Joined: Wed May 21, 2008 9:54 am
Posts: 8
Not sure I can do this, and I can't find any documentation that says either way..

lets say we have a child that has a many to one to its parent, I want to select all children, but ordered by a property of their parent, e.g.

myOrderClause = new Order("Parent.SomeProperty", true)

Is this permissible ? or do I have to write an HQL query that joins to the parent and then do my order within that statement ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 10:59 am 
Senior
Senior

Joined: Thu Jun 21, 2007 8:03 am
Posts: 127
Location: UK
Hi MarkC,

You should be able to order by the parent column as long as you alias it.

For example:
Code:
IList<Child> children =
    session.CreateCriteria(typeof(Child))
        .CreateAlias("Parent", "Parent")
        .Add(Order.Asc("Parent.SomeProperty"))
        .List<Child>();


Regards,
Richard


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.