Hi I'm trying to get the total Count of a list with groovy totalCount
but it throws:
Exception evaluating property 'totalCount' for java.util.ArrayList,
Reason: groovy.lang.MissingPropertyException: No such property: totalCount
Is there anyway that I can get the total count with groovy totalCount
instead of .size
?
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 {
// ...
}