When you do a criteria query in Grails the list you get back will only offer a totalCount
if you invoked the query with pagination parameters (offset
and max
)
params.max = params.max ?: 10
def resultWithTotalCount = MyDomain.createCriteria().list(params) {
// ...
}
A plain list
call without pagination will return a non-paged list which does not have the totalCount
property
def resultWithoutTotalCount = MyDomain.createCriteria().list {
// ...
}