I am trying to retrieve values from a database using IN. I realized that I need to write a JPA request, for example
o.country IN (’UK’, ’US’, ’France’)
so I tried to write a request
List result = Playlist.find("id in ?", values).fetch();
Where values=set of integers
but it cannot compile at runtime
java.lang.ClassCastException: java.util.HashSet cannot be cast to java.lang.Integer
How to fix it?
Fixed
I also posted this in google groups and got an answer that seems to work
List<Integer> countries = (list of integers for ’UK’, ’US’, ’France’)
List result = Playlist.find("id in (:countries)").bind("countries",
countries).fetch();
source
share