Grails criteria projections - get rows count

前端 未结 2 1020
轮回少年
轮回少年 2021-02-12 17:49

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 h         


        
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-12 18:24

    There are dynamic counters as well as finders on domain objects:

    Hotel.countByCity(city)
    

    More details in the user guide, of course

提交回复
热议问题