3
I가 (관련된 성질)은 다음 도메인 클래스 :Grails는 GORM 이중 중첩 연관 검색어
class Order {
static belongsTo = [ restaurant : Restaurant ]
}
class Restaurant {
static belongsTo = [ country : Country ]
}
class Country {
}
테이블 구조가 잘되고 데이터가 정확하게 생성된다. 그러나 레스토랑이 특정 국가에 속한 모든 주문 목록을 얻으려고하면입니다. 한 주문 만받습니다. 여기
는 것을 증명하는 데 실패 테스트입니다 :def testOrdersByCountry(){
given:
def c = new Country().save()
def r = new Restaurant(country:c).save()
new Order(restaurant:r).save()
new Order(restaurant:r).save()
new Order(restaurant:r).save()
when:
def orders = Order.withCriteria {
restaurant {
country {
eq 'id', c.id
}
}
}
then:
orders.size() == 3
}