문제

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 {
  // ...
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top