diff --git a/documentation/src/main/asciidoc/introduction/Interacting.adoc b/documentation/src/main/asciidoc/introduction/Interacting.adoc index fc0c693f1e..2252626228 100644 --- a/documentation/src/main/asciidoc/introduction/Interacting.adoc +++ b/documentation/src/main/asciidoc/introduction/Interacting.adoc @@ -997,7 +997,8 @@ The `getResultCount()` method is useful for displaying the number of pages of re SelectionQuery query = session.createSelectionQuery("from Book where title like ?1 order by title", Book.class) .setParameter(1, titlePattern); -long pages = (long) Math.ceil(query.getResultCount() * 1.0 / MAX_RESULTS); +long results = query.getResultCount(); +long pages = results / MAX_RESULTS + (results % MAX_RESULTS == 0 ? 0 : 1); List books = query.setMaxResults(MAX_RESULTS).getResultList(); ----