I have the following domain classes (with relevant properties):
class Order {
static belongsTo = [ restaurant : Restaurant ]
}
class Restaurant {
static belongsTo = [ country : Country ]
}
class Country {
}
The table structure is fine and data is generated correctly. But when I try to get a list of all orders whose restaurant belongs to a specific country, I only get ONE order.
Here is a test that fails to prove that:
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
}