-->
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: Ordering problem
PostPosted: Thu Aug 25, 2005 7:20 am 
Newbie

Joined: Sat Aug 13, 2005 4:08 pm
Posts: 2
Hello developers,

I have an object, lets say `Parent`. In this Parent I have a lazy `Set` of `Child` objects. `Child` object has a field `ChildName`. `ChildName` has a field `name`. I would like to get `Parents` (using Criteria) and order their `Children` by their `ChildName.name`. How to do it? Mapping Set only allows to order-by column, so ie. by `Child.name`, not `Child.ChildName.name`.

Best regards,
Konrad Billewicz


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 9:29 am 
Newbie

Joined: Fri Jul 30, 2004 9:02 am
Posts: 9
Location: Ukraine
You can sort elements in collection using such mapping
<set name="detailedTasks" cascade="all" lazy="true" sort="DetailedTasksComparator">
sort="class name where described comparator for Child class"
then for adding elements to collection in parent object you should use implementation of sortable collection, TreeSet in this case.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 9:32 am 
Newbie

Joined: Fri Jul 30, 2004 9:02 am
Posts: 9
Location: Ukraine
There is described well
http://www.hibernate.org/hib_docs/v3/reference/en/html/collections.html#collections-sorted


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 2:01 pm 
Newbie

Joined: Sat Aug 13, 2005 4:08 pm
Posts: 2
Tomorow at work I will test it, but it looks very nice. I had searched documentation previously but haven't found this chapter. Thank you for your help.

Best regards,
Konrad Billewicz


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.