2

所以我有这个标准查询,它得到了 10 篇具有 itemchannel 对象的特征文章,这些对象的类型为 4,并且在 id 1 的频道中,即让我获得前 10 篇文章,这些文章的类型为特征并且在频道 x 中。

def criteria = Feature.createCriteria()
list = criteria.list {
    maxResults(params.max)
    itemChannels {
        eq ('itemType.id',(long)4)
        eq ('channel.id',(long)1)
    }
}

我如何有效地获得总数,即我有第 1 页的文章,但我需要分页总数?

谢谢

4

1 回答 1

0

认为我对此进行了排序。

criteria = Feature.createCriteria()
count = criteria.get{
    projections {
        countDistinct('id')
    }
    itemChannels {
        eq ('itemType.id',(long)4)
        eq ('channel.id',(long)2)
    }
}
于 2011-10-29T11:09:55.940 回答