grails create query:totalCount的分页错误



我使用的是带分页的条件查询。查询工作正常,但totalCount大于预期的计数。是否存在重复问题?

def idList =  CS.createCriteria().list (params) {
      projections { distinct ( "id" ) 
          property("date")
          property("id")
      }
      cpNames{
           eq("login",login)    
}
      order("date","desc")
}
   return idList

在gsp端,分页(idList.totalCount)是错误的:比我的列表大。

listDistinct()方法不能很好地与分页选项maxResult和firstResult配合使用。如果您需要不同的分页结果,我们目前建议您使用HQL。你可以从这篇博客文章中了解更多信息。

http://grails.org/doc/latest/guide/GORM.html#criteria

最新更新