开发者

"IN" statement in play using hql

开发者 https://www.devze.com 2023-02-22 03:55 出处:网络
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)

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

精彩评论

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