gpt4 book ai didi

grails - 嵌套hasOne实体的GORM查询条件

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

我正在尝试通过子实体的属性创建GORM条件查询过滤。所以有这样的实体:

class PaymentEntry {

static hasOne = [category: PaymentCategory]

static constraints = {
category(nullable: true)
}

// other stuff
}

class PaymentCategory {

static hasMany = [payments: PaymentEntry]

// other stuff
}

现在,我尝试选择具有特定类别的PaymentEntries。我正在尝试这样的事情:
def c = PaymentEntry.createCriteria()

def res = c {
'in'("category", categories)
}
categories这里是较早选择的 PaymentCategory实体的列表。

不幸的是,这失败了。 Grails抛出NoSuchMethodException。

最佳答案

您应该有inList。
试试这个:

def res = c {
inList("category", categories)
}

关于grails - 嵌套hasOne实体的GORM查询条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36225123/

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