I는 도메인 클래스 가지고Grails는 GORM MissingMethodException이 : N의 관계
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.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
작동합니다.
여기 무슨 일 이니?
그게 효과가! 왜 내 포인터를 줄 수 있니? 서비스 필드의 줄에있는 뭔가가 ServicesGroup 개체로 선언되므로 서비스를 사용하여 물건을 검색하려면 주어진 유형의 개체를 사용해야합니까? findBy */get 중첩없이 동일한 결과를 얻는 직접적인 방법이 있습니까? 감사합니다. – Karolis
아래의 다른 답변을 참조하십시오. 세 번째 방법은 Hibernate 기준을 사용하고 Step.withCriteria {service {eq ("id", 3}}}를 수행하는 것입니다. –