我有这样的 Realm 类:
class ServicesGroup {
Long id
String name
String description
String toString(){
return name
}
static mapping = {
version false
table 'root.services_groups'
id column:'group_id'
name column:'group_name'
description column:'group_desc'
}
}
和
class Step {
Long id
ServicesGroup service
String stepType
Integer stepFrom
Integer stepTo
static constraints = {
stepType(inList:['operator', 'client'])
}
static mapping = {
version false
table 'bill.steps'
service column:'service_group_id'
}
}
关系是-一个ServicesGroup条目可以具有多个Step实例。
但是,当我在 Controller 中时,
Step.findByService(3)
我得到:
"org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: Step.findByService() is applicable for argument types: (java.lang.Integer) values: {3}"
但是,当我更改Step域类字段时
ServicesGroup service
简单地
Long service
有用。
这里发生了什么?
最佳答案
尝试这种方式:
Step.findByService(ServicesGroup.get(3))
关于grails - 具有1:N关系的Grails GORM MissingMethodException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/896683/