Grails/GORM“进入”标准
是否可以使用 GORM 标准执行“in”标准。我正在寻找与以下 SQL 等效的内容
select * from Person where age in (20,21,22);
如果可能的话我猜语法会类似于:
def results = Person.withCriteria {
in "age", [20, 21, 22]
}
Is it possible to do an "in" criteria using the GORM criteria. I'm looking for the equivalent of the following SQL
select * from Person where age in (20,21,22);
If it was possible I guess the syntax would be something like:
def results = Person.withCriteria {
in "age", [20, 21, 22]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Grails createCriteria 文档包含使用
的示例in
子句:文档包含以下注释:
The Grails createCriteria documentation includes an example of using the
in
clause:The documentation includes this note:
是的,你说的几乎完全正确。只需将
in
更改为'in'
,因为in
是 groovy 中的关键字。Yep, you have it almost exactly right. Just change
in
to'in'
, sincein
is a keyword in groovy.