Reputation: 7750
How can I get the same results in Play Framework's Model Queries?
SELECT * FROM MyModel WHERE status IN (1, 5, 8) ORDER BY createdAt;
Upvotes: 3
Views: 3106
Reputation: 54924
Have you tried
MyModel.find("status IN (:ids) ORDER BY createdAt").bind("ids", idExs).fetch();
Upvotes: 7
Reputation: 242726
If (1, 5, 8)
is a constant, it's pretty straightforward:
List<MyModel> r = MyModel.find("status in (1, 5, 8) order by createdAt").fetch();
If it should be a parameter:
List<Integer> s = Arrays.asList(1, 5, 8);
List<MyModel> r = MyModel.find("status in :s order by createdAt")
.bind("s", s).fetch();
An important point here is that you can use in
clause with named parameters only, not with positional (?
) ones, due to limitation of Hibernate.
Upvotes: 1