Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Multiple Field Sorting
PostPosted: Fri Feb 24, 2012 7:09 am 
Regular
Regular

Joined: Tue May 17, 2011 1:45 am
Posts: 52
Hi,

I have a situation where the index has 4 fields

Field 1 : city_name
Field 2 : city_name_locale
Field 3 : country name
Field 4 : country_name_locale

I need to sort the result such that field 1 is sorted first and next field 2 .

USing SortField(....,....) is not working , any suggestions?

Regards
David


Top
 Profile  
 
 Post subject: Re: Multiple Field Sorting
PostPosted: Fri Feb 24, 2012 7:59 am 
Newbie

Joined: Wed Sep 21, 2011 2:20 pm
Posts: 16
if I remember it correct it should be similar to the following:

SortField[] sort = new SortField[2];
sort[0] = new SortField("city_name", SortField.STRING);
sort[1] = new SortField("city_name_locale", SortField.STRING);

query.setSort( new Sort(sort));
query.list();

at least that was how it worked in the past. I do not know, whether that has changed in a newer version.

kind regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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.