我有这样的 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)) 


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!