gpt4 book ai didi

grails - GORM中是否有 'not in'等效项?

转载 作者:行者123 更新时间:2023-12-04 04:48:06 24 4
gpt4 key购买 nike

是否可以在createCriteria()中进行转换?

SELECT * FROM node WHERE (node.type = 'act' AND nid NOT IN (SELECT nid FROM snbr_act_community)) LIMIT 10

我知道这里有一个“in”运算符,到目前为止,这是我所拥有的:
def c = VolunteerOpportunity.createCriteria()
def matchingActs = c.list {
node {
eq('type', 'act')
}
maxResults(10)
}

只想看看这是否可行。否则,我想这在HQL中是可能的,对吗?

最佳答案

感谢Sammyrulez提供的代码。从中得到了一个主意。测试了它,但是没有用。我修复了它,这是最终的工作代码:

def ids = [14400 as long, 14401 as long]

def c = VolunteerOpportunity.createCriteria()
def matchingActs = c.list {
node {
eq('type', 'act')
not { 'in'(ids) }
}
maxResults(10)
}

现在我知道如何使用“不”运算符。多谢!

关于grails - GORM中是否有 'not in'等效项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3423020/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com