I have Hotel entity:
class Hotel {
City city
}
Now, i need count of hotels with given city.
It could be done in this way:
def hotels = Hotel.findAllByCity(city)
def cnt = hotels.size()
But it’s very dirty way. It seems that with criteria it would be better, but i have no idea how to implement it…
There are dynamic counters as well as finders on domain objects:
More details in the user guide, of course