Reputation: 12582
List<Prize> prizes =
sessionProvider.getCurrentSession().createQuery("from Prize where id in (:ids)")
.setParameterList("ids", prizeIds).list();
I have a list of prizeIds, which are not unique. I need to fetch Prize objects for each id. But hibernate returns me only unique elements list. How can i get a list same size as the input list.
Upvotes: 0
Views: 224
Reputation: 1107
UPDATE: The thing that you collection has multiple ids changes the things. Certainly Hibernate is doing his job so you must find another solution.
To answear the question properly: It is impossible to get non-distinct results using "in".
Upvotes: 0
Reputation: 4030
The answer you are getting is default functionality of "in" function in database. Use exist or not exist clause to retrieve the records for every id. I doubt whether you can use exist or not exists as well.
But, be sure about the functionality you are trying to achieve, this is not something very common in most of the applications
Upvotes: 1