Grails GORM MissingMethodException with 1: N ratio

I have domain classes like this:

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'
    }
}

      

and

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'
    }
}

      

Relationships - One ServiceGroup entry can have multiple Step instances.

However, when in my controller I try

Step.findByService(3)

      

I get:

"org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: Step.findByService() is applicable for argument types: (java.lang.Integer) values: {3}"

      

However, when I change the domain class field Step

ServicesGroup service

      

just

Long service

      

it works.

What's going on here?

+1


a source to share


3 answers


Try this:



Step.findByService(ServicesGroup.get(3))

      

+3


a source


Try

grails clean
grails run-app

      



Then try again.

+1


a source


Perhaps something like Step.findByService ([id: 3]). It takes care of the ID anyway for SQL generation purposes. In many cases, for example, you can flip a fake card and not the real thing and save yourself some performance.

On the other hand, the abstraction shrinks a bit when you do this.

+1


a source