【问题标题】:Grails query not inListGrails 查询不在列表中
【发布时间】:2012-05-02 11:44:33
【问题描述】:

我正在编写一个条件来进行查询,但我不知道如何否定 inList 条件...有没有办法做类似的事情:

def result = c {
     not inList('id', ids)
}

谢谢

【问题讨论】:

    标签: grails grails-orm criteria


    【解决方案1】:

    你的标准应该是这样的......

    def ids = [1, 2, 3];
    
    def c = Foo.createCriteria();
    def results = c.list {
      not {'in'("id",ids)}
    }
    

    可以在here 找到文档。我相信这只是在 grails 2.+ 中添加的。

    【讨论】:

    • 你是对的...除了 not 方法似乎不存在
    • @rascio 添加可能毫无意义,因为已经过去了 3 年多,但是.. 需要在传递之前转换为数组 (toArray())。
    猜你喜欢
    • 1970-01-01
    • 2016-11-16
    • 1970-01-01
    • 2017-03-19
    • 1970-01-01
    • 2016-01-13
    • 2016-01-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多