"IN" statement in play using hql
How can I write an HQL query like same SQL query like this:
select * from User开发者_StackOverflow社区s u where u.id in (1, 3, 4)
Try User.find("id in (:ids)").bind("ids", new Long[]{1L,3L,4L}).fetch()
I suggest you use native query to utilize your SQL query, so that you don't have to convert to HQL.
The simplest way to do this with play is
public static void findByIds(List<Long> userIds) {
find("from Users u where u.id in (?1)", userIds).fetch();
}
精彩评论