문제

그러한 도메인 클래스가 있습니다.

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

관계는 - 하나의 서비스 그룹 항목에 여러 단계 인스턴스를 가질 수 있습니다.

그러나 컨트롤러에있을 때 나는 노력합니다

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

그러나 단계 도메인 클래스 필드를 변경하면

ServicesGroup service

간단히

Long service

효과가있다.

여기서 무슨 일이야?

도움이 되었습니까?

해결책

그런 식으로 시도해보십시오.

Step.findByService(ServicesGroup.get(3))

다른 팁

노력하다

grails clean
grails run-app

그런 다음 다시 시도하십시오.

step.findbyservice ([id : 3])와 같은 것이 작동 할 수 있습니다. 그것은 SQL 생성의 목적으로 어쨌든 ID에 대해서만 관심이 있습니다. 이와 같은 많은 경우에서 당신은 실제가 아닌 가짜지도를 거기에 던져서 성능을 저장할 수 있습니다.

반면에, 당신이 이것을 할 때 추상화는 약간 분해됩니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top