且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在hibernate中实现结果分页(获取总行数)

更新时间:2023-02-05 23:41:49

您可以使用Query.setMaxResults(int results)和Query.setFirstResult(int offset)。

You can use Query.setMaxResults(int results) and Query.setFirstResult(int offset).

编辑太:没有办法知道你会得到多少结果。所以,首先你必须查询select count(*)...。有点丑陋,IMHO。

Editing too: There's no way to know how many results you'll get. So, first you must query with "select count(*)...". A little ugly, IMHO.