Skip to content

Commit 2f59edb

Browse files
nathan.xugavinking
authored andcommitted
HHH-18588 improve page computing
1 parent 942474f commit 2f59edb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

documentation/src/main/asciidoc/introduction/Interacting.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,8 @@ The `getResultCount()` method is useful for displaying the number of pages of re
997997
SelectionQuery<Book> query =
998998
session.createSelectionQuery("from Book where title like ?1 order by title", Book.class)
999999
.setParameter(1, titlePattern);
1000-
long pages = (long) Math.ceil(query.getResultCount() * 1.0 / MAX_RESULTS);
1000+
long results = query.getResultCount();
1001+
long pages = results / MAX_RESULTS + (results % MAX_RESULTS == 0 ? 0 : 1);
10011002
List<Book> books = query.setMaxResults(MAX_RESULTS).getResultList();
10021003
----
10031004

0 commit comments

Comments
 (0)