We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 942474f commit 2f59edbCopy full SHA for 2f59edb
documentation/src/main/asciidoc/introduction/Interacting.adoc
@@ -997,7 +997,8 @@ The `getResultCount()` method is useful for displaying the number of pages of re
997
SelectionQuery<Book> query =
998
session.createSelectionQuery("from Book where title like ?1 order by title", Book.class)
999
.setParameter(1, titlePattern);
1000
-long pages = (long) Math.ceil(query.getResultCount() * 1.0 / MAX_RESULTS);
+long results = query.getResultCount();
1001
+long pages = results / MAX_RESULTS + (results % MAX_RESULTS == 0 ? 0 : 1);
1002
List<Book> books = query.setMaxResults(MAX_RESULTS).getResultList();
1003
----
1004
0 commit comments