开发者

"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();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜