grailswere子句,为什么我不能搜索id==id的位置?

grailswere子句,为什么我不能搜索id==id的位置?,grails,gorm,where,Grails,Gorm,Where,这一直困扰着我一段时间。以下查询工作正常: Receipt.where{project.customer == customer}.list() 但是这个查询抛出了一个异常 Receipt.where{project.customer.id==customer.id}.list() 例外情况: 阶级 groovy.lang.MissingMethodException消息 方法receiptbucketserver.Customer.call()的签名不适用于参数类型: (receiptbu

这一直困扰着我一段时间。以下查询工作正常:

Receipt.where{project.customer == customer}.list()
但是这个查询抛出了一个异常

Receipt.where{project.customer.id==customer.id}.list()
例外情况:

阶级 groovy.lang.MissingMethodException消息 方法receiptbucketserver.Customer.call()的签名不适用于参数类型: (receiptbucketserver.ReceiptHelperService$\u tt\u getReceiptsByCustomer\u Closure 11\u Closure 12\u Closure 13) 价值观: [receiptbucketserver.ReceiptHelperService$\u tt\u getReceiptsByCustomer\u Closure 11\u Closure 12_closure13@170130c3] 可能的解决方案:wait()、last()、save()、any()、getAll(), 等待(长)


您可以尝试下面的代码
def receiptCriteria={project{customer{eq('id',customerId)}}}def results=Receipt.findAll(receiptCriteria)
在第一个代码段中,您正在比较对象,在第二个代码段中,您正在比较对象的属性。where方法似乎只接受对象进行比较。