Repository: jakartaee/data
Pull request #650 (2024-04-04 17:55:52)

fixes to Javadoc
- fallout from removal of type variable from `PageRequest`
- removal of some uses of `{@code }` inside `<pre>`, which renders  extremely weirdly in IntelliJ
- improve description of ordering in `@OrderBy`


Patch:
diff --git a/api/src/main/java/jakarta/data/Order.java b/api/src/main/java/jakarta/data/Order.java
index b19c95ce..0e109981 100644
--- a/api/src/main/java/jakarta/data/Order.java
+++ b/api/src/main/java/jakarta/data/Order.java
@@ -37,14 +37,13 @@ import jakarta.data.repository.OrderBy;
  * sort criteria during development. For example,</p>
  *
  * <pre>
- * {@code Page<Employee>} findByYearHired(int year, {@code PageRequest<Employee>} pageRequest);
+ * Page&lt;Employee>&gt; findByYearHired(int year, PageRequest pageRequest, Order&lt;Employee&gt;);
  * ...
  * page1 = employees.findByYearHired(Year.now(),
+ *                                   PageRequest.ofSize(10).page(1),
  *                                   Order.by(_Employee.salary.desc(),
  *                                            _Employee.lastName.asc(),
- *                                            _Employee.firstName.asc())
- *                                        .page(1)
- *                                        .size(10));
+ *                                            _Employee.firstName.asc()));
  * </pre>
  *
  * <p>The relative precedence of an instance of {@link Sort} belonging
diff --git a/api/src/main/java/jakarta/data/metamodel/StaticMetamodel.java b/api/src/main/java/jakarta/data/metamodel/StaticMetamodel.java
index 99c2a029..67869fa5 100644
--- a/api/src/main/java/jakarta/data/metamodel/StaticMetamodel.java
+++ b/api/src/main/java/jakarta/data/metamodel/StaticMetamodel.java
@@ -85,12 +85,11 @@ import jakarta.data.Sort;
  * <p>And use it to refer to entity attributes in a type-safe manner,</p>
  *
  * <pre>
- * {@code PageRequest<Product>} pageRequest = Order.by(_Person.yearOfBirth.desc(),
- *                                             _Person.name_last.asc(),
- *                                             _Person.name_first.asc(),
- *                                             _Person.ssn.asc())
- *                                         .page(1)
- *                                         .size(20);
+ * Order&lt;Person&gt; order =
+ *         Order.by(_Person.yearOfBirth.desc(),
+ *                  _Person.name_last.asc(),
+ *                  _Person.name_first.asc(),
+ *                  _Person.ssn.asc());
  * </pre>
  *
  * <p>Alternatively, an annotation processor might generate static metamodel classes
diff --git a/api/src/main/java/jakarta/data/page/CursoredPage.java b/api/src/main/java/jakarta/data/page/CursoredPage.java
index a899b46f..054b0bde 100644
--- a/api/src/main/java/jakarta/data/page/CursoredPage.java
+++ b/api/src/main/java/jakarta/data/page/CursoredPage.java
@@ -57,13 +57,13 @@ import java.util.NoSuchElementException;
  * &#64;OrderBy("lastName")
  * &#64;OrderBy("firstName")
  * &#64;OrderBy("id")
- * CursoredPage&lt;Employee&gt; findByHoursWorkedGreaterThan(int hours, {@code PageRequest<Employee>} pageRequest);
+ * CursoredPage&lt;Employee&gt; findByHoursWorkedGreaterThan(int hours, PageRequest pageRequest);
  * </pre>
  *
  * <p>In initial page may be requested using an offset-based page request:</p>
  *
  * <pre>
- * page = employees.findByHoursWorkedGreaterThan(1500, PageRequest.of(Employee.class).size(50));
+ * page = employees.findByHoursWorkedGreaterThan(1500, PageRequest.ofSize(50));
  * </pre>
  *
  * <p>The next page may be requested relative to the end of the current page,
@@ -87,9 +87,9 @@ import java.util.NoSuchElementException;
  *
  * <pre>
  * Employee emp = ...
- * {@code PageRequest<Employee>} pageRequest = PageRequest.of(Employee.class)
- *                                                .size(50)
- *                                                .afterKey(emp.lastName, emp.firstName, emp.id);
+ * PageRequest pageRequest =
+ *         PageRequest.ofSize(50)
+ *                    .afterKey(emp.lastName, emp.firstName, emp.id);
  * page = employees.findByHoursWorkedGreaterThan(1500, pageRequest);
  * </pre>
  *
diff --git a/api/src/main/java/jakarta/data/page/Page.java b/api/src/main/java/jakarta/data/page/Page.java
index 491371fc..9c458b5e 100644
--- a/api/src/main/java/jakarta/data/page/Page.java
+++ b/api/src/main/java/jakarta/data/page/Page.java
@@ -28,11 +28,12 @@ import java.util.stream.StreamSupport;
  * an argument of a repository method. For example,</p>
  *
  * <pre>
- * {@code @Find}
- * {@code Page<Vehicle>} search({@code @By("make")} String make,
- *                       {@code @By("model")} String model,
- *                       {@code @By("year")} int designYear,
- *                       {@code PageRequest<Vehicle>} pageRequest);
+ * &#64;Find
+ * Page&lt;Vehicle&gt; search(&#64;By("make") String make,
+ *                      &#64;By("model") String model,
+ *                      &#64;By("year") int designYear,
+ *                      PageRequest pageRequest,
+ *                      Order&lt;Vehicle&gt; order);
  * </pre>
  *
  * <p>If {@link PageRequest#requestTotal()} is enabled, the {@link Page} also
diff --git a/api/src/main/java/jakarta/data/page/Pagination.java b/api/src/main/java/jakarta/data/page/Pagination.java
index cc6fad38..26a67905 100644
--- a/api/src/main/java/jakarta/data/page/Pagination.java
+++ b/api/src/main/java/jakarta/data/page/Pagination.java
@@ -17,10 +17,6 @@
  */
 package jakarta.data.page;
 
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
 import java.util.Optional;
 
 /**
@@ -70,20 +66,6 @@ record Pagination(long page, int size, Mode mode, Cursor type, boolean requestTo
         return new Pagination(page, size, Mode.CURSOR_PREVIOUS, cursor, requestTotal);
     }
 
-
-    private static <E> List<E> combine(List<E> list, E element) {
-        int size = list.size();
-        if (size == 0) {
-            return java.util.List.of(element);
-        } else {
-            Object[] array = list.toArray(new Object[size + 1]);
-            array[size] = element;
-            @SuppressWarnings("unchecked")
-            List<E> newList = (List<E>) Collections.unmodifiableList(Arrays.asList(array));
-            return newList;
-        }
-    }
-
     @Override
     public Optional<Cursor> cursor() {
         return Optional.ofNullable(type);
diff --git a/api/src/main/java/jakarta/data/repository/BasicRepository.java b/api/src/main/java/jakarta/data/repository/BasicRepository.java
index 6c66cbaa..e0e736b8 100644
--- a/api/src/main/java/jakarta/data/repository/BasicRepository.java
+++ b/api/src/main/java/jakarta/data/repository/BasicRepository.java
@@ -17,6 +17,7 @@
  */
 package jakarta.data.repository;
 
+import jakarta.data.Order;
 import jakarta.data.exceptions.OptimisticLockingFailureException;
 import jakarta.data.page.Page;
 import jakarta.data.page.PageRequest;
@@ -160,14 +161,15 @@ public interface BasicRepository<T, K> extends DataRepository<T, K> {
      * Returns a {@link Page} of entities according to the page request that is provided as the {@link PageRequest} parameter.
      *
      * @param pageRequest the request for a paginated result; must not be {@code null}.
+     * @param sortBy      sort criteria that must deterministically order the results; must not be {@code null}.
      * @return a page of entities; will never be {@code null}.
-     * @throws NullPointerException when {@code pageRequest} is {@code null}.
+     * @throws NullPointerException when {@code pageRequest} or {@code sortBy} is {@code null}.
      * @throws UnsupportedOperationException for Key-Value and Wide-Column databases when the {@link PageRequest.Mode#CURSOR_NEXT}
      * or {@link PageRequest.Mode#CURSOR_PREVIOUS} pagination mode is selected.
      * @see PageRequest.Mode
      */
     @Find
-    Page<T> findAll(PageRequest pageRequest);
+    Page<T> findAll(PageRequest pageRequest, Order<T> sortBy);
 
     /**
      * Deletes the entity with the given Id.
diff --git a/api/src/main/java/jakarta/data/repository/OrderBy.java b/api/src/main/java/jakarta/data/repository/OrderBy.java
index 97ae974d..fcdb4421 100644
--- a/api/src/main/java/jakarta/data/repository/OrderBy.java
+++ b/api/src/main/java/jakarta/data/repository/OrderBy.java
@@ -44,13 +44,20 @@ import java.lang.annotation.Target;
  * <pre>
  * &#64;OrderBy("lastName")
  * &#64;OrderBy("firstName")
- * Person[] findByZipCode(int zipCode, {@code PageRequest<?>} pageRequest);
+ * &#64;OrderBy("id")
+ * Person[] findByZipCode(int zipCode, PageRequest pageRequest);
  * </pre>
  *
- * <p>The precise meaning of ascending and descending order is
- * defined by the database, but generally ascending order for
- * numeric values means smaller numbers before larger numbers and for
- * string values means {@code A} before {@code Z}.</p>
+ * <p>The interpretation of ascending and descending order is determined
+ * by the database, but, in general:
+ * <ul>
+ * <li>ascending order for numeric values is the natural order with
+ *     smaller numbers before larger numbers,</li>
+ * <li>ascending order for string values is lexicographic order with
+ *     {@code A} before {@code Z}, and</li>
+ * <li>ascending order for boolean values places {@code false} before
+ *     {@code true}.</li>
+ * </ul>
  *
  * <p>A repository method with an {@code @OrderBy} annotation must not
  * have:</p>
diff --git a/api/src/main/java/jakarta/data/repository/Param.java b/api/src/main/java/jakarta/data/repository/Param.java
index 50ab0c73..cda93bff 100644
--- a/api/src/main/java/jakarta/data/repository/Param.java
+++ b/api/src/main/java/jakarta/data/repository/Param.java
@@ -29,12 +29,12 @@ import java.lang.annotation.Target;
  * <p>For example,</p>
  *
  * <pre>
- * {@code @Repository}
- * public interface Products extends BasicRepository{@code <Product, String>} {
+ * &#64;Repository
+ * public interface Products extends BasicRepository&lt;Product, String&gt; {
  *
- *     {@code @Query("WHERE length * width * height <= :maxVolume")}
- *     {@code Page<Product>} freeShippingEligible({@code @Param}("maxVolume") float volumeLimit,
- *                                        {@code PageRequest<?>} pageRequest);
+ *     &#64;Query("WHERE length * width * height &lt;= :maxVolume ORDER BY price ASC, id ASC")
+ *     Page&lt;Product&gt; freeShippingEligible(&#64;Param("maxVolume") float volumeLimit,
+ *                                        PageRequest pageRequest);
  *
  *     ...
  * }
diff --git a/api/src/main/java/jakarta/data/repository/Query.java b/api/src/main/java/jakarta/data/repository/Query.java
index 38cea18c..12ae7d22 100644
--- a/api/src/main/java/jakarta/data/repository/Query.java
+++ b/api/src/main/java/jakarta/data/repository/Query.java
@@ -18,7 +18,6 @@
 package jakarta.data.repository;
 
 import jakarta.data.Sort;
-import jakarta.data.page.Page;
 
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
@@ -74,26 +73,28 @@ import java.lang.annotation.Target;
  * <p>For example,</p>
  *
  * <pre>
- * {@code @Repository}
- * public interface People extends CrudRepository{@code <Person, Long>} {
+ * &#64;Repository
+ * public interface People extends CrudRepository&lt;Person, Long&gt; {
  *
  *     // JDQL with positional parameters
- *     {@code @Query("where firstName = ?1 and lastName = ?2")}
- *     {@code List<Person>} byName(String first, String last);
+ *     &#64;Query("where firstName = ?1 and lastName = ?2")
+ *     List&lt;Person&gt; byName(String first, String last);
  *
  *     // JDQL with a named parameter
- *     {@code @Query("where firstName || ' ' || lastName like :pattern")}
- *     {@code List<Person>} byName(String pattern);
+ *     &#64;Query("where firstName || ' ' || lastName like :pattern")
+ *     List&lt;Person&gt; byName(String pattern);
  *
  *     // JPQL using a positional parameter
- *     {@code @Query("from Person where extract(year from birthdate) = ?1")}
- *     {@code List<Person>} bornIn(int year);
+ *     &#64;Query("from Person where extract(year from birthdate) = ?1")
+ *     List&lt;Person&gt; bornIn(int year);
  *
  *     // JPQL using named parameters
- *     {@code @Query("select distinct name from Person where length(name) >= :min and length(name) <= :max")}
- *     {@code Page<String>} namesOfLength({@code @Param}("min") int minLength,
- *                                {@code @Param}("max") int maxLength,
- *                                {@code PageRequest<Person>} pageRequest);
+ *     &#64;Query("select distinct name from Person " +
+ *            "where length(name) &gt;= :min and length(name) &lt;= :max")
+ *     Page&lt;String&gt; namesOfLength(&#64;Param("min") int minLength,
+ *                                &#64;Param("max") int maxLength,
+ *                                PageRequest pageRequest,
+ *                                Order&lt;Person&gt; order);
  *
  *     ...
  * }
diff --git a/api/src/main/java/module-info.java b/api/src/main/java/module-info.java
index a4f752e1..98c8d61f 100644
--- a/api/src/main/java/module-info.java
+++ b/api/src/main/java/module-info.java
@@ -773,35 +773,27 @@ import java.util.Set;
  *
  * <pre>
  * Product[] findByNameLikeOrderByAmountSoldDescNameAsc(
- *           String pattern, {@code PageRequest<Product>} pageRequest);
+ *           String pattern, PageRequest pageRequest);
  * ...
  * page1 = products.findByNameLikeOrderByAmountSoldDescNameAsc(
- *                  "%phone%", PageRequest.of(Product.class).size(20));
+ *                  "%phone%", PageRequest.ofSize(20));
  * </pre>
  *
  * <h3>Sorting</h3>
  *
  * <p>When a page is requested with a {@code PageRequest}, dynamic sorting
  * criteria may be supplied by passing instances of {@link Sort} or {@link Order}.
- * and its overloads. For example,</p>
+ * For example,</p>
  *
  * <pre>
- * Product[] findByNameLike(String pattern, {@code PageRequest<Product>} pagination);
+ * Product[] findByNameLike(String pattern, PageRequest pageRequest, Order&lt;Product&gt; order);
  *
  * ...
  * PageRequest page1Request = PageRequest.ofSize(25);
  *
  * page1 = products.findByNameLikeAndPriceBetween(
- *                 namePattern, minPrice, maxPrice, page1Request, Order.by(Sort.desc("price"),Sort.asc("name"));
- * </pre>
- *
- * <p>An alternative when using the {@link StaticMetamodel} is to obtain the
- * page request from an {@link Order} instance, as follows,</p>
- *
- * <pre>
- * {@code PageRequest<Product>} pageRequest = Order.by(_Product.price.desc(),
- *                                             _Product.name.asc())
- *                                         .pageSize(25));
+ *                 namePattern, minPrice, maxPrice, page1Request,
+ *                 Order.by(Sort.desc("price"), Sort.asc("name"));
  * </pre>
  *
  * <p>To supply sort criteria dynamically without using pagination, an
@@ -809,13 +801,13 @@ import java.util.Set;
  * of {@link Sort} and passed to the repository find method. For example,</p>
  *
  * <pre>
- * Product[] findByNameLike(String pattern, Limit max, {@code Order<Product>} sortBy);
+ * Product[] findByNameLike(String pattern, Limit max, Order&lt;Product&gt; sortBy);
  *
  * ...
- * found = products.findByNameLike(namePattern, Limit.of(25), Order.by(
- *                                 Sort.desc("price"),
- *                                 Sort.desc("amountSold"),
- *                                 Sort.asc("name")));
+ * found = products.findByNameLike(namePattern, Limit.of(25),
+ *                                 Order.by(Sort.desc("price"),
+ *                                          Sort.desc("amountSold"),
+ *                                          Sort.asc("name")));
  * </pre>
  *
  * <p>Generic, untyped {@link Sort} criteria can be supplied directly to a
diff --git a/spec/src/main/asciidoc/repository.asciidoc b/spec/src/main/asciidoc/repository.asciidoc
index 5efadcb5..88347dec 100644
--- a/spec/src/main/asciidoc/repository.asciidoc
+++ b/spec/src/main/asciidoc/repository.asciidoc
@@ -36,7 +36,7 @@ A repository interface may inherit methods from a superinterface.
 A superinterface of a repository interface must either:
 
 - be one of the built-in generic repository supertypes defined by this specification, `DataRepository`, `BasicRepository`, or `CrudRepository`, or
-- be a non-generic toplevel interface with no type parameters, whose abstract methods likewise declare no type parameters.
+- be a non-generic toplevel interface with no type parameters, whose abstract methods likewise declare no type parameters, and which does not itself directly or indirectly inherit any generic interface or any interface whose abstract methods declare type parameters.
 
 A Jakarta Data implementation must treat abstract methods inherited by a repository interface as if they were directly declared by the repository interface.
 
diff --git a/tck/src/main/java/ee/jakarta/tck/data/framework/read/only/AsciiCharacters.java b/tck/src/main/java/ee/jakarta/tck/data/framework/read/only/AsciiCharacters.java
index 84a25b71..6127781d 100644
--- a/tck/src/main/java/ee/jakarta/tck/data/framework/read/only/AsciiCharacters.java
+++ b/tck/src/main/java/ee/jakarta/tck/data/framework/read/only/AsciiCharacters.java
@@ -72,7 +72,7 @@ public interface AsciiCharacters extends DataRepository<AsciiCharacter, Long>, I
 
     Optional<AsciiCharacter> findByNumericValue(int id);
 
-    Page<AsciiCharacter> findByNumericValueBetween(int min, int max, PageRequest<AsciiCharacter> pagination);
+    Page<AsciiCharacter> findByNumericValueBetween(int min, int max, PageRequest pagination, Order<AsciiCharacter> order);
 
     List<AsciiCharacter> findByNumericValueLessThanEqualAndNumericValueGreaterThanEqual(int max, int min);
 
diff --git a/tck/src/main/java/ee/jakarta/tck/data/framework/read/only/NaturalNumbers.java b/tck/src/main/java/ee/jakarta/tck/data/framework/read/only/NaturalNumbers.java
index 124277ac..889fe481 100644
--- a/tck/src/main/java/ee/jakarta/tck/data/framework/read/only/NaturalNumbers.java
+++ b/tck/src/main/java/ee/jakarta/tck/data/framework/read/only/NaturalNumbers.java
@@ -43,7 +43,7 @@ public interface NaturalNumbers extends BasicRepository<NaturalNumber, Long>, Id
     long countBy();
 
     CursoredPage<NaturalNumber> findByFloorOfSquareRootOrderByIdAsc(long sqrtFloor,
-                                                                    PageRequest<NaturalNumber> pagination);
+                                                                    PageRequest pagination);
 
     Stream<NaturalNumber> findByIdBetweenOrderByNumTypeAsc(long minimum,
                                                            long maximum,
@@ -58,20 +58,23 @@ public interface NaturalNumbers extends BasicRepository<NaturalNumber, Long>, Id
     List<NaturalNumber> findByIdLessThanEqual(long maximum, Sort<?>... sorts);
 
     Page<NaturalNumber> findByIdLessThanOrderByFloorOfSquareRootDesc(long exclusiveMax,
-                                                                     PageRequest<NaturalNumber> pagination);
+                                                                     PageRequest pagination,
+                                                                     Order<NaturalNumber> order);
 
     CursoredPage<NaturalNumber> findByNumTypeAndNumBitsRequiredLessThan(NumberType type,
                                                                         short bitsUnder,
-                                                                        PageRequest<NaturalNumber> pagination);
+                                                                        Order<NaturalNumber> order,
+                                                                        PageRequest pagination);
 
     NaturalNumber[] findByNumTypeNot(NumberType notThisType, Limit limit, Order<NaturalNumber> sorts);
 
     Page<NaturalNumber> findByNumTypeAndFloorOfSquareRootLessThanEqual(NumberType type,
                                                                        long maxSqrtFloor,
-                                                                       PageRequest<NaturalNumber> pagination);
+                                                                       PageRequest pagination,
+                                                                       Sort<NaturalNumber> sort);
 
     @Query("SELECT id WHERE isOdd = true AND id BETWEEN 21 AND ?1 ORDER BY id ASC")
-    Page<Long> oddsFrom21To(long max, PageRequest<NaturalNumber> pageRequest);
+    Page<Long> oddsFrom21To(long max, PageRequest pageRequest);
 
     @Query("WHERE isOdd = false AND numType = ee.jakarta.tck.data.framework.read.only.NaturalNumber.NumberType.PRIME")
     Optional<NaturalNumber> two();
diff --git a/tck/src/main/java/ee/jakarta/tck/data/framework/read/only/PositiveIntegers.java b/tck/src/main/java/ee/jakarta/tck/data/framework/read/only/PositiveIntegers.java
index 7e273a2b..801ac939 100644
--- a/tck/src/main/java/ee/jakarta/tck/data/framework/read/only/PositiveIntegers.java
+++ b/tck/src/main/java/ee/jakarta/tck/data/framework/read/only/PositiveIntegers.java
@@ -23,6 +23,7 @@ import java.util.stream.Stream;
 import ee.jakarta.tck.data.framework.read.only.NaturalNumber.NumberType;
 import jakarta.data.Limit;
 import jakarta.data.Order;
+import jakarta.data.Sort;
 import jakarta.data.page.CursoredPage;
 import jakarta.data.page.Page;
 import jakarta.data.page.PageRequest;
@@ -45,7 +46,8 @@ public interface PositiveIntegers extends BasicRepository<NaturalNumber, Long> {
 
     CursoredPage<NaturalNumber> findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(long excludeSqrt,
                                                                                                   long eclusiveMax,
-                                                                                                  PageRequest<NaturalNumber> pagination);
+                                                                                                  PageRequest pagination,
+                                                                                                  Order<NaturalNumber> order);
 
     List<NaturalNumber> findByIsOddTrueAndIdLessThanEqualOrderByIdDesc(long max);
 
@@ -57,7 +59,7 @@ public interface PositiveIntegers extends BasicRepository<NaturalNumber, Long> {
 
     @Find
     Page<NaturalNumber> findMatching(long floorOfSquareRoot, Short numBitsRequired, NumberType numType,
-            PageRequest<NaturalNumber> pagination);
+            PageRequest pagination, Sort<?>... sorts);
 
     @Find
     Optional<NaturalNumber> findNumber(long id);
@@ -73,5 +75,7 @@ public interface PositiveIntegers extends BasicRepository<NaturalNumber, Long> {
     CursoredPage<NaturalNumber> withBitCountOrOfTypeAndBelow(@Param("bits") short bitsRequired,
                                                              @Param("type") NumberType numberType,
                                                              @Param("xmax") long exclusiveMax,
-                                                             PageRequest<?> pageRequest);
+                                                             Sort<NaturalNumber> sort1,
+                                                             Sort<NaturalNumber> sort2,
+                                                             PageRequest pageRequest);
 }
\ No newline at end of file


Test patch:
diff --git a/tck/src/main/java/ee/jakarta/tck/data/standalone/entity/EntityTests.java b/tck/src/main/java/ee/jakarta/tck/data/standalone/entity/EntityTests.java
index db5c5982..3d49b92b 100644
--- a/tck/src/main/java/ee/jakarta/tck/data/standalone/entity/EntityTests.java
+++ b/tck/src/main/java/ee/jakarta/tck/data/standalone/entity/EntityTests.java
@@ -352,10 +352,10 @@ public class EntityTests {
 
     @Assertion(id = "133", strategy = "Request a Page higher than the final Page, expecting an empty Page with 0 results.")
     public void testBeyondFinalPage() {
-        PageRequest<AsciiCharacter> sixth = Order.by(_AsciiCharacter.numericValue.asc()).page(6).size(10);
+        PageRequest sixth = PageRequest.ofPage(6).size(10);
         Page<AsciiCharacter> page;
         try {
-            page = characters.findByNumericValueBetween(48, 90, sixth);
+            page = characters.findByNumericValueBetween(48, 90, sixth, Order.by(_AsciiCharacter.numericValue.asc()));
         } catch (UnsupportedOperationException x) {
             // Some NoSQL databases lack the ability to count the total results
             // and therefore cannot support a return type of Page
@@ -371,9 +371,9 @@ public class EntityTests {
 
     @Assertion(id = "133", strategy = "Request a Slice higher than the final Slice, expecting an empty Slice with 0 results.")
     public void testBeyondFinalSlice() {
-        PageRequest<NaturalNumber> sixth = PageRequest.of(NaturalNumber.class).size(5).sortBy(Sort.desc("id")).page(6).withoutTotal();
+        PageRequest sixth = PageRequest.ofSize(5).page(6).withoutTotal();
         Page<NaturalNumber> page = numbers.findByNumTypeAndFloorOfSquareRootLessThanEqual(NumberType.PRIME, 8L,
-                sixth);
+                sixth, Sort.desc("id"));
         assertEquals(0, page.numberOfElements());
         assertEquals(0, page.stream().count());
         assertEquals(false, page.hasContent());
@@ -499,10 +499,11 @@ public class EntityTests {
 
     @Assertion(id = "133", strategy = "Request the last Page of up to 10 results, expecting to find the final 3.")
     public void testFinalPageOfUpTo10() {
-        PageRequest<AsciiCharacter> fifthPageRequest = Order.by(_AsciiCharacter.numericValue.asc()).pageSize(10).page(5);
+        PageRequest fifthPageRequest = PageRequest.ofSize(10).page(5);
         Page<AsciiCharacter> page;
         try {
-            page = characters.findByNumericValueBetween(48, 90, fifthPageRequest); // 'X' to 'Z'
+            page = characters.findByNumericValueBetween(48, 90, fifthPageRequest,
+                                                        Order.by(_AsciiCharacter.numericValue.asc())); // 'X' to 'Z'
         } catch (UnsupportedOperationException x) {
             // Some NoSQL databases lack the ability to count the total results
             // and therefore cannot support a return type of Page
@@ -547,9 +548,9 @@ public class EntityTests {
 
     @Assertion(id = "133", strategy = "Request the last Slice of up to 5 results, expecting to find the final 2.")
     public void testFinalSliceOfUpTo5() {
-        PageRequest<NaturalNumber> fifth = PageRequest.of(NaturalNumber.class).size(5).page(5).sortBy(Sort.desc("id")).withoutTotal();
+        PageRequest fifth = PageRequest.ofSize(5).page(5).withoutTotal();
         Page<NaturalNumber> page = numbers.findByNumTypeAndFloorOfSquareRootLessThanEqual(NumberType.PRIME, 8L,
-                fifth);
+                fifth, Sort.desc("id"));
         assertEquals(true, page.hasContent());
         assertEquals(5, page.pageRequest().page());
         assertEquals(2, page.numberOfElements());
@@ -583,9 +584,9 @@ public class EntityTests {
                           "ascending and descending sort. Verify the page contains all 12 expected entities, " +
                           "sorted according to the mixture of ascending and descending sort orders specified.")
     public void testFindAllWithPagination() {
-        PageRequest<NaturalNumber> page2request = PageRequest.of(NaturalNumber.class).page(2).size(12)
-                .sortBy(Sort.asc("floorOfSquareRoot"), Sort.desc("id"));
-        Page<NaturalNumber> page2 = positives.findAll(page2request);
+        PageRequest page2request = PageRequest.ofPage(2).size(12);
+        Page<NaturalNumber> page2 = positives.findAll(page2request,
+                                                      Order.by(Sort.asc("floorOfSquareRoot"), Sort.desc("id")));
 
         assertEquals(12, page2.numberOfElements());
         assertEquals(2, page2.pageRequest().page());
@@ -681,10 +682,10 @@ public class EntityTests {
     @Assertion(id = "133",
                strategy = "Find a page of entities, with entity attributes identified by the parameter names and matching the parameter values.")
     public void testFindPage() {
-        PageRequest<NaturalNumber> page1Request = PageRequest.of(NaturalNumber.class).size(7).sortBy(Sort.desc("id"));
+        PageRequest page1Request = PageRequest.ofSize(7);
 
         Page<NaturalNumber> page1 = positives.findMatching(9L, Short.valueOf((short) 7), NumberType.COMPOSITE,
-                                                           page1Request);
+                                                           page1Request, Sort.desc("id"));
 
         assertEquals(List.of(99L, 98L, 96L, 95L, 94L, 93L, 92L),
                      page1.stream().map(NaturalNumber::getId).collect(Collectors.toList()));
@@ -692,7 +693,7 @@ public class EntityTests {
         assertEquals(true, page1.hasNext());
 
         Page<NaturalNumber> page2 = positives.findMatching(9L, Short.valueOf((short) 7), NumberType.COMPOSITE,
-                                                           page1.nextPageRequest());
+                                                           page1.nextPageRequest(), Sort.desc("id"));
 
         assertEquals(List.of(91L, 90L, 88L, 87L, 86L, 85L, 84L),
                      page2.stream().map(NaturalNumber::getId).collect(Collectors.toList()));
@@ -700,7 +701,7 @@ public class EntityTests {
         assertEquals(true, page2.hasNext());
 
         Page<NaturalNumber> page3 = positives.findMatching(9L, Short.valueOf((short) 7), NumberType.COMPOSITE,
-                                                           page2.nextPageRequest());
+                                                           page2.nextPageRequest(), Sort.desc("id"));
 
         assertEquals(List.of(82L, 81L),
                      page3.stream().map(NaturalNumber::getId).collect(Collectors.toList()));
@@ -722,11 +723,12 @@ public class EntityTests {
         // 2, 3 requires 2 bits
         // 1 requires 1 bit
 
-        PageRequest<NaturalNumber> first8 = PageRequest.of(NaturalNumber.class).size(8).sortBy(Sort.asc("id"));
+        Order<NaturalNumber> order = Order.by(Sort.asc("id"));
+        PageRequest first8 = PageRequest.ofSize(8);
         CursoredPage<NaturalNumber> page;
 
         try {
-            page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(4L, 33L, first8);
+            page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(4L, 33L, first8, order);
         } catch (UnsupportedOperationException x) {
             // Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database
             // is not capable of cursor-based pagination.
@@ -739,7 +741,7 @@ public class EntityTests {
                      Arrays.toString(page.stream().map(number -> number.getId()).toArray()));
 
         try {
-            page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(4L, 33L, page.nextPageRequest());
+            page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(4L, 33L, page.nextPageRequest(), order);
         } catch (UnsupportedOperationException x) {
             // Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database
             // is not capable of cursor-based pagination.
@@ -752,7 +754,7 @@ public class EntityTests {
         assertEquals(8, page.numberOfElements());
 
         try {
-            page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(4L, 33L, page.nextPageRequest());
+            page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(4L, 33L, page.nextPageRequest(), order);
         } catch (UnsupportedOperationException x) {
             // Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database
             // is not capable of cursor-based pagination.
@@ -770,7 +772,7 @@ public class EntityTests {
                           "then request the next CursoredPage and the CursoredPage after that, " +
                           "expecting to find all results.")
     public void testFirstCursoredPageWithoutTotalOf6AndNextPages() {
-        PageRequest<NaturalNumber> first6 = PageRequest.of(NaturalNumber.class).size(6).withoutTotal();
+        PageRequest first6 = PageRequest.ofSize(6).withoutTotal();
         CursoredPage<NaturalNumber> slice;
 
         try {
@@ -817,10 +819,11 @@ public class EntityTests {
                strategy = "Request the first Page of 10 results, expecting to find all 10. " +
                           "From the Page, verify the totalElements and totalPages expected.")
     public void testFirstPageOf10() {
-        PageRequest<AsciiCharacter> first10 = Order.by(_AsciiCharacter.numericValue.asc()).pageSize(10);
+        PageRequest first10 = PageRequest.ofSize(10);
         Page<AsciiCharacter> page;
         try {
-            page = characters.findByNumericValueBetween(48, 90, first10); // '0' to 'Z'
+            page = characters.findByNumericValueBetween(48, 90, first10,
+                                                        Order.by(_AsciiCharacter.numericValue.asc())); // '0' to 'Z'
         } catch (UnsupportedOperationException x) {
             // Some NoSQL databases lack the ability to count the total results
             // and therefore cannot support a return type of Page
@@ -841,9 +844,9 @@ public class EntityTests {
 
     @Assertion(id = "133", strategy = "Request the first Slice of 5 results, expecting to find all 5.")
     public void testFirstSliceOf5() {
-        PageRequest<NaturalNumber> first5 = PageRequest.of(NaturalNumber.class).size(5).sortBy(Sort.desc("id")).withoutTotal();
+        PageRequest first5 = PageRequest.ofSize(5).withoutTotal();
         Page<NaturalNumber> page = numbers.findByNumTypeAndFloorOfSquareRootLessThanEqual(NumberType.PRIME, 8L,
-                first5);
+                first5, Sort.desc("id"));
         assertEquals(5, page.numberOfElements());
 
         Iterator<NaturalNumber> it = page.iterator();
@@ -937,13 +940,13 @@ public class EntityTests {
         //                                        ^^^ previous page ^^
         //                                                                                  ^^^^^ next page ^^^^
 
-        PageRequest<NaturalNumber> middle7 = PageRequest.of(NaturalNumber.class).size(7)
-                        .sortBy(Sort.asc("floorOfSquareRoot"), Sort.desc("id"))
+        Order<NaturalNumber> order = Order.by(Sort.asc("floorOfSquareRoot"), Sort.desc("id"));
+        PageRequest middle7 = PageRequest.ofSize(7)
                         .afterKey((short) 5, 5L, 26L); // 20th result is 26; it requires 5 bits and its square root rounds down to 5.
 
         CursoredPage<NaturalNumber> page;
         try {
-            page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(6L, 50L, middle7);
+            page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(6L, 50L, middle7, order);
         } catch (UnsupportedOperationException x) {
             // Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database
             // is not capable of cursor-based pagination.
@@ -963,7 +966,8 @@ public class EntityTests {
         CursoredPage<NaturalNumber> previousPage;
         try {
             previousPage = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(6L, 50L,
-                                                                                                    page.previousPageRequest());
+                                                                                                    page.previousPageRequest(),
+                                                                                                    order);
         } catch (UnsupportedOperationException x) {
             // Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database
             // is not capable of cursor-based pagination.
@@ -980,7 +984,8 @@ public class EntityTests {
         CursoredPage<NaturalNumber> nextPage;
         try {
             nextPage = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(6L, 50L,
-                                                                                                page.nextPageRequest());
+                                                                                                page.nextPageRequest(),
+                                                                                                order);
         } catch (UnsupportedOperationException x) {
             // Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database
             // is not capable of cursor-based pagination.
@@ -1002,7 +1007,7 @@ public class EntityTests {
         CursoredPage<NaturalNumber> page;
         try {
             // There are no positive integers less than 4 which have a square root that rounds down to something other than 1.
-            page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(1L, 4L, PageRequest.ofPage(1L));
+            page = positives.findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(1L, 4L, PageRequest.ofPage(1L), Order.by());
         } catch (UnsupportedOperationException x) {
             // Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database
             // is not capable of cursor-based pagination.
@@ -1022,13 +1027,6 @@ public class EntityTests {
             // expected
         }
 
-        try {
-            page.nextPageRequest(NaturalNumber.class);
-            fail("nextPageRequest(entityClass) must raise NoSuchElementException when current page is empty.");
-        } catch (NoSuchElementException x) {
-            // expected
-        }
-
         try {
             page.previousPageRequest();
             fail("previousPageRequest must raise NoSuchElementException when current page is empty.");
@@ -1049,13 +1047,13 @@ public class EntityTests {
         //                                  ^^^^^^^^ slice 2 ^^^^^^^^^
         //                                                                                        ^^^^^^^^ slice 3 ^^^^^^^^^
 
-        PageRequest<NaturalNumber> middle9 = PageRequest.of(NaturalNumber.class).size(9).withoutTotal()
-                             .sortBy(Sort.desc("floorOfSquareRoot"), Sort.asc("id"))
+        PageRequest middle9 = PageRequest.ofSize(9).withoutTotal()
                              .afterKey(6L, 46L); // 20th result is 46; its square root rounds down to 6.
+        Order<NaturalNumber> order = Order.by(Sort.desc("floorOfSquareRoot"), Sort.asc("id"));
 
         CursoredPage<NaturalNumber> slice;
         try {
-            slice = numbers.findByNumTypeAndNumBitsRequiredLessThan(NumberType.COMPOSITE, (short) 7, middle9);
+            slice = numbers.findByNumTypeAndNumBitsRequiredLessThan(NumberType.COMPOSITE, (short) 7, order, middle9);
         } catch (UnsupportedOperationException x) {
             // Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database
             // is not capable of cursor-based pagination.
@@ -1072,6 +1070,7 @@ public class EntityTests {
         try {
             previousSlice = numbers.findByNumTypeAndNumBitsRequiredLessThan(NumberType.COMPOSITE,
                                                                             (short) 7,
+                                                                            order,
                                                                             slice.previousPageRequest());
         } catch (UnsupportedOperationException x) {
             // Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database
@@ -1088,6 +1087,7 @@ public class EntityTests {
          try {
              nextSlice = numbers.findByNumTypeAndNumBitsRequiredLessThan(NumberType.COMPOSITE,
                                                                          (short) 7,
+                                                                         order,
                                                                          slice.nextPageRequest());
          } catch (UnsupportedOperationException x) {
              // Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database
@@ -1104,7 +1104,7 @@ public class EntityTests {
     @Assertion(id = "133", strategy = "Request a CursoredPage of results where none match the query, expecting an empty CursoredPage with 0 results.")
     public void testCursoredPageWithoutTotalOfNothing() {
         // There are no numbers larger than 30 which have a square root that rounds down to 3.
-        PageRequest<NaturalNumber> pagination = PageRequest.of(NaturalNumber.class).size(33).afterKey(30L).withoutTotal();
+        PageRequest pagination = PageRequest.ofSize(33).afterKey(30L).withoutTotal();
 
         CursoredPage<NaturalNumber> slice;
         try {
@@ -1209,12 +1209,12 @@ public class EntityTests {
 
         assertEquals(true, page1.hasNext());
 
-        Page<Long> page2 = numbers.oddsFrom21To(40L, page1.nextPageRequest(NaturalNumber.class));
+        Page<Long> page2 = numbers.oddsFrom21To(40L, page1.nextPageRequest());
 
         assertEquals(List.of(31L, 33L, 35L, 37L, 39L), page2.content());
 
         if (page2.hasNext()) {
-            Page<Long> page3 = numbers.oddsFrom21To(40L, page2.nextPageRequest(NaturalNumber.class));
+            Page<Long> page3 = numbers.oddsFrom21To(40L, page2.nextPageRequest());
             assertEquals(false, page3.hasContent());
             assertEquals(false, page3.hasNext());
         }
@@ -1281,8 +1281,10 @@ public class EntityTests {
                           "verfying that all results are returned and are ordered first by the static sort criteria, " +
                           "followed by the dynamic sort criteria when the value(s) being compared by the static criteria match.")
     public void testOrderByHasPrecedenceOverPageRequestSorts() {
-        PageRequest<NaturalNumber> pagination = PageRequest.of(NaturalNumber.class).size(8).sortBy(Sort.asc("numType"), Sort.desc("id"));
-        Page<NaturalNumber> page = numbers.findByIdLessThanOrderByFloorOfSquareRootDesc(25L, pagination);
+        PageRequest pagination = PageRequest.ofSize(8);
+        Order<NaturalNumber> order = Order.by(Sort.asc("numType"), Sort.desc("id"));
+
+        Page<NaturalNumber> page = numbers.findByIdLessThanOrderByFloorOfSquareRootDesc(25L, pagination, order);
 
         assertEquals(Arrays.toString(new Long[] { 23L, 19L, 17L, // square root rounds down to 4; prime
                                                   24L, 22L, 21L, 20L, 18L }), // square root rounds down to 4; composite
@@ -1290,7 +1292,7 @@ public class EntityTests {
 
         assertEquals(true, page.hasNext());
         pagination = page.nextPageRequest();
-        page = numbers.findByIdLessThanOrderByFloorOfSquareRootDesc(25L, pagination);
+        page = numbers.findByIdLessThanOrderByFloorOfSquareRootDesc(25L, pagination, order);
 
         assertEquals(Arrays.toString(new Long[] { 16L, // square root rounds down to 4; composite
                                                   13L, 11L, // square root rounds down to 3; prime
@@ -1299,7 +1301,7 @@ public class EntityTests {
 
         assertEquals(true, page.hasNext());
         pagination = page.nextPageRequest();
-        page = numbers.findByIdLessThanOrderByFloorOfSquareRootDesc(25L, pagination);
+        page = numbers.findByIdLessThanOrderByFloorOfSquareRootDesc(25L, pagination, order);
 
         assertEquals(Arrays.toString(new Long[] { 7L, 5L, // square root rounds down to 2; prime
                                                   8L, 6L, 4L, // square root rounds down to 2; composite
@@ -1309,7 +1311,7 @@ public class EntityTests {
 
         if (page.hasNext()) {
             pagination = page.nextPageRequest();
-            page = numbers.findByIdLessThanOrderByFloorOfSquareRootDesc(25L, pagination);
+            page = numbers.findByIdLessThanOrderByFloorOfSquareRootDesc(25L, pagination, order);
             assertEquals(false, page.hasContent());
         }
     }
@@ -1334,10 +1336,11 @@ public class EntityTests {
 
     @Assertion(id = "133", strategy = "Request a Page of results where none match the query, expecting an empty Page with 0 results.")
     public void testPageOfNothing() {
-        PageRequest<AsciiCharacter> pagination = Order.by(_AsciiCharacter.id.asc()).pageSize(6);
+        PageRequest pagination = PageRequest.ofSize(6);
         Page<AsciiCharacter> page;
         try {
-            page = characters.findByNumericValueBetween(150, 160, pagination);
+            page = characters.findByNumericValueBetween(150, 160, pagination,
+                                                        Order.by(_AsciiCharacter.id.asc()));
         } catch (UnsupportedOperationException x) {
             // Some NoSQL databases lack the ability to count the total results
             // and therefore cannot support a return type of Page
@@ -1402,12 +1405,14 @@ public class EntityTests {
 
     @Assertion(id = "458", strategy = "Use a repository method with a JDQL query that relies on the OR operator.")
     public void testQueryWithOr() {
-        PageRequest<?> page1Request = PageRequest.ofSize(4).sortBy(Sort.desc("numBitsRequired"), Sort.asc("id"));
+        PageRequest page1Request = PageRequest.ofSize(4);
         CursoredPage<NaturalNumber> page1;
 
         try {
             page1 = positives.withBitCountOrOfTypeAndBelow((short) 4,
                                                            NumberType.COMPOSITE, 20L,
+                                                           Sort.desc("numBitsRequired"),
+                                                           Sort.asc("id"),
                                                            page1Request);
         } catch (UnsupportedOperationException x) {
             // Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database
@@ -1430,6 +1435,8 @@ public class EntityTests {
         try {
             page2 = positives.withBitCountOrOfTypeAndBelow((short) 4,
                                                            NumberType.COMPOSITE, 20L,
+                                                           Sort.desc("numBitsRequired"),
+                                                           Sort.asc("id"),
                                                            page1.nextPageRequest());
         } catch (UnsupportedOperationException x) {
             // Test passes: Jakarta Data providers must raise UnsupportedOperationException when the database
@@ -1446,6 +1453,8 @@ public class EntityTests {
 
         CursoredPage<NaturalNumber> page3 = positives.withBitCountOrOfTypeAndBelow((short) 4,
                                                                                    NumberType.COMPOSITE, 20L,
+                                                                                   Sort.desc("numBitsRequired"),
+                                                                                   Sort.asc("id"),
                                                                                    page2.nextPageRequest());
 
         assertEquals(List.of(14L, 15L, 4L, 6L),
@@ -1456,6 +1465,8 @@ public class EntityTests {
         if (page3.hasNext()) {
             CursoredPage<NaturalNumber> page4 = positives.withBitCountOrOfTypeAndBelow((short) 4,
                                                                                        NumberType.COMPOSITE, 20L,
+                                                                                       Sort.desc("numBitsRequired"),
+                                                                                       Sort.asc("id"),
                                                                                        page3.nextPageRequest());
             assertEquals(false, page4.hasContent());
         }
@@ -1479,9 +1490,9 @@ public class EntityTests {
 
     @Assertion(id = "133", strategy = "Request a Slice of results where none match the query, expecting an empty Slice with 0 results.")
     public void testSliceOfNothing() {
-        PageRequest<NaturalNumber> pagination =  PageRequest.of(NaturalNumber.class).size(5).sortBy(Sort.desc("id")).withoutTotal();
+        PageRequest pagination =  PageRequest.ofSize(5).withoutTotal();
         Page<NaturalNumber> page = numbers.findByNumTypeAndFloorOfSquareRootLessThanEqual(NumberType.COMPOSITE, 1L,
-                pagination);
+                pagination, Sort.desc("id"));
 
         assertEquals(false, page.hasContent());
         assertEquals(0, page.content().size());
@@ -1494,8 +1505,9 @@ public class EntityTests {
         assertEquals(Sort.ascIgnoreCase(_AsciiChar.HEXADECIMAL), _AsciiChar.hexadecimal.ascIgnoreCase());
         assertEquals(Sort.ascIgnoreCase("thisCharacter"), _AsciiChar.thisCharacter.ascIgnoreCase());
 
-        PageRequest<AsciiCharacter> pageRequest = Order.by(_AsciiChar.numericValue.asc()).pageSize(6);
-        Page<AsciiCharacter> page1 = characters.findByNumericValueBetween(68, 90, pageRequest);
+        PageRequest pageRequest = PageRequest.ofSize(6);
+        Page<AsciiCharacter> page1 = characters.findByNumericValueBetween(68, 90, pageRequest,
+                                                                          Order.by(_AsciiChar.numericValue.asc()));
 
         assertEquals(List.of('D', 'E', 'F', 'G', 'H', 'I'),
                      page1.stream()
@@ -1510,8 +1522,9 @@ public class EntityTests {
         assertEquals(Sort.ascIgnoreCase(_AsciiCharacter.HEXADECIMAL), _AsciiCharacter.hexadecimal.ascIgnoreCase());
         assertEquals(Sort.ascIgnoreCase("thisCharacter"), _AsciiCharacter.thisCharacter.ascIgnoreCase());
 
-        PageRequest<AsciiCharacter> pageRequest = Order.by(_AsciiCharacter.numericValue.asc()).pageSize(7);
-        Page<AsciiCharacter> page1 = characters.findByNumericValueBetween(100, 122, pageRequest);
+        PageRequest pageRequest = PageRequest.ofSize(7);
+        Page<AsciiCharacter> page1 = characters.findByNumericValueBetween(100, 122, pageRequest,
+                                                                          Order.by(_AsciiCharacter.numericValue.asc()));
 
         assertEquals(List.of('d', 'e', 'f', 'g', 'h', 'i', 'j'),
                      page1.stream()
@@ -1598,10 +1611,11 @@ public class EntityTests {
                strategy = "Request the third Page of 10 results, expecting to find all 10. " +
                           "Request the next Page via nextPageRequest, expecting page number 4 and another 10 results.")
     public void testThirdAndFourthPagesOf10() {
-        PageRequest<AsciiCharacter> third10 = Order.by(_AsciiCharacter.numericValue.asc()).page(3).size(10);
+        Order<AsciiCharacter> order = Order.by(_AsciiCharacter.numericValue.asc());
+        PageRequest third10 = PageRequest.ofPage(3).size(10);
         Page<AsciiCharacter> page;
         try {
-            page = characters.findByNumericValueBetween(48, 90, third10); // 'D' to 'M'
+            page = characters.findByNumericValueBetween(48, 90, third10, order); // 'D' to 'M'
         } catch (UnsupportedOperationException x) {
             // Some NoSQL databases lack the ability to count the total results
             // and therefore cannot support a return type of Page
@@ -1620,8 +1634,8 @@ public class EntityTests {
                                      .reduce("", String::concat));
 
         assertEquals(true, page.hasNext());
-        PageRequest<AsciiCharacter> fourth10 = page.nextPageRequest();
-        page = characters.findByNumericValueBetween(48, 90, fourth10); // 'N' to 'W'
+        PageRequest fourth10 = page.nextPageRequest();
+        page = characters.findByNumericValueBetween(48, 90, fourth10, order); // 'N' to 'W'
 
         assertEquals(4, page.pageRequest().page());
         assertEquals(true, page.hasContent());
@@ -1639,9 +1653,10 @@ public class EntityTests {
                strategy = "Request the third Slice of 5 results, expecting to find all 5. "
                        +  "Request the next Slice via nextPageRequest, expecting page number 4 and another 5 results.")
     public void testThirdAndFourthSlicesOf5() {
-        PageRequest<NaturalNumber> third5 = PageRequest.of(NaturalNumber.class).page(3).size(5).sortBy(Sort.desc("id")).withoutTotal();
+        PageRequest third5 = PageRequest.ofPage(3).size(5).withoutTotal();
+        Sort<NaturalNumber> sort = Sort.desc("id");
         Page<NaturalNumber> page = numbers.findByNumTypeAndFloorOfSquareRootLessThanEqual(NumberType.PRIME, 8L,
-                third5);
+                third5, sort);
 
         assertEquals(3, page.pageRequest().page());
         assertEquals(5, page.numberOfElements());
@@ -1650,9 +1665,9 @@ public class EntityTests {
                 Arrays.toString(page.stream().map(number -> number.getId()).toArray()));
 
         assertEquals(true, page.hasNext());
-        PageRequest<NaturalNumber> fourth5 = page.nextPageRequest();
+        PageRequest fourth5 = page.nextPageRequest();
 
-        page = numbers.findByNumTypeAndFloorOfSquareRootLessThanEqual(NumberType.PRIME, 8L, fourth5);
+        page = numbers.findByNumTypeAndFloorOfSquareRootLessThanEqual(NumberType.PRIME, 8L, fourth5, sort);
 
         assertEquals(4, page.pageRequest().page());
         assertEquals(5, page.numberOfElements());