Is there a more efficient way of making pagination in Hibernate than executing select and count queries?

前端 未结 11 1314
说谎
说谎 2020-12-04 16:36

Usually pagination queries look like this. Is there a better way instead of making two almost equal methods, one of which executing \"select *...\" and the other one \"count

11条回答
  •  情深已故
    2020-12-04 17:36

    At this Hibernate wiki page:

    https://www.hibernate.org/314.html

    I present a complete pagination solution; in particular, the total number of elements is computed by scrolling to the end of the resultset, which is supported by now by several JDBC drivers. This avoids the second "count" query.

提交回复
热议问题