-->
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: help! sorting Map using Session.filter
PostPosted: Thu Oct 16, 2003 7:44 pm 
Newbie

Joined: Thu Oct 16, 2003 7:22 pm
Posts: 12
How do I sort a many-to-many collection mapped as a Map using filter?

For example, if I have a map between Student and Class with 'priority' as the map key.

and I want to sort the list of Classes for a student based on the class name. (the sorting criteria is decided by the user at runtime)

looks like when I use
Code:
Session.filter(map, "ORDER BY this.name ASC")
the resulting collection is a List (!) containing elements of Class in the specified order, which is great except I cannot retrieve the Map key (priority) any more.

Any help would be greatly appreciated....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 16, 2003 10:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
I have not played with filtering of a Map, so I'm not sure its even doable. What I have done instead is to use a java.util.SortedMap (or mapped the Map collection with an appropriate sorter). Would this work for you?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 17, 2003 2:42 am 
Newbie

Joined: Thu Oct 16, 2003 7:22 pm
Posts: 12
we it does work... the collection that comes back is a List in the desired order, except of course without the Map key...

A SortedMap would not work because I want to sort on the fields of the value, not the key.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 19, 2003 11:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I havn't tried this, but it should work:


select index(this), this order by this.name asc

which will return a List of ordered pairs.

(Hibernate 2.1 only.)


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.