-->
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.  [ 1 post ] 
Author Message
 Post subject: Keep order of retrieved entities as the id order in the list
PostPosted: Tue Jun 08, 2010 3:32 am 
Newbie

Joined: Tue Jun 08, 2010 3:01 am
Posts: 1
Hello,
I have a method with 2 arguments, 1st a list of ids, 2nd a criteria. I need to retrieve the entities using the passed criteria but in the same order of the ids in the idList argument.

Code:
public class User{
private Long id;
....}

Code:
public List<User> getUsers(List<Long> idList, Criteria criteria){
List<User> results=criteria.add(Restrictions.in("id",idList)).list();
return results;
}

The problem is that the returned list does not respect the id order in the idList argument. What should be done to retrieve the entities in the same order?


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

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.