Skip to content

Commit eb6cb31

Browse files
committed
add some javadoc to KeyedResultList, Order, Page
1 parent 65b9b43 commit eb6cb31

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

hibernate-core/src/main/java/org/hibernate/query/KeyedResultList.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
* }
4848
* </pre>
4949
*
50+
* @apiNote This class is similar to {@code jakarta.data.page.CursoredPage},
51+
* and is used by Hibernate Data Repositories to implement
52+
* Jakarta Data query methods.
53+
*
5054
* @since 6.5
5155
*
5256
* @see KeyedPage

hibernate-core/src/main/java/org/hibernate/query/Order.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,22 @@
2020
* <p>
2121
* This is a convenience class which allows query result ordering
2222
* rules to be passed around the system before being applied to
23-
* a {@link Query} by calling {@link SelectionQuery#setOrder}.
23+
* a {@link Query} by calling {@link SelectionQuery#setOrder(Order)}.
24+
* <pre>
25+
* session.createSelectionQuery("from Book b join b.authors a where a.name = :name", Book.class)
26+
* .setParameter("name", authorName)
27+
* .setOrder(asc(Book_.publicationDate))
28+
* .getResultList();
29+
* </pre>
30+
* <p>
31+
* {@code Order}s may be stacked using {@link List#of} and
32+
* {@link SelectionQuery#setOrder(List)}.
33+
* <pre>
34+
* session.createSelectionQuery("from Book b join b.authors a where a.name = :name", Book.class)
35+
* .setParameter("name", authorName)
36+
* .setOrder(List.of(asc(Book_.publicationDate), desc(Book_.ssn)))
37+
* .getResultList();
38+
* </pre>
2439
* <p>
2540
* A parameter of a {@linkplain org.hibernate.annotations.processing.Find
2641
* finder method} or {@linkplain org.hibernate.annotations.processing.HQL
@@ -30,6 +45,10 @@
3045
*
3146
* @param <X> The result type of the query to be sorted
3247
*
48+
* @apiNote This class is similar to {@code jakarta.data.Sort}, and is
49+
* used by Hibernate Data Repositories to implement Jakarta Data
50+
* query methods.
51+
*
3352
* @see SelectionQuery#setOrder(Order)
3453
* @see SelectionQuery#setOrder(java.util.List)
3554
*

hibernate-core/src/main/java/org/hibernate/query/Page.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@
1010

1111
/**
1212
* Identifies a page of query results by {@linkplain #size page size}
13-
* and {@linkplain #number page number}.
13+
* and {@linkplain #number page number}. This is an alternative to the
14+
* use of the JPA-defined operations {@link SelectionQuery#setFirstResult}
15+
* and {@link SelectionQuery#setMaxResults}.
16+
* <pre>
17+
* session.createSelectionQuery("from Book b join b.authors a where a.name = :name", Book.class)
18+
* .setParameter("name", authorName)
19+
* .setPage(Page.first(100))
20+
* .getResultList();
21+
* </pre>
1422
* <p>
1523
* This is a convenience class which allows a reference to a page of
16-
* results to be passed around the system before being applied to
17-
* a {@link Query} by calling {@link Query#setPage(Page)}.
24+
* results to be passed around the system before being applied to a
25+
* {@link Query} by calling {@link Query#setPage(Page)}.
1826
* <p>
1927
* A parameter of a {@linkplain org.hibernate.annotations.processing.Find
2028
* finder method} or {@linkplain org.hibernate.annotations.processing.HQL
@@ -23,6 +31,10 @@
2331
* For key-based pagination, call {@link #keyedBy(Order)} to obtain a
2432
* {@link KeyedPage}.
2533
*
34+
* @apiNote This class is similar to {@code jakarta.data.page.PageRequest},
35+
* and is used by Hibernate Data Repositories to implement
36+
* Jakarta Data query methods.
37+
*
2638
* @see SelectionQuery#setPage(Page)
2739
*
2840
* @since 6.3

0 commit comments

Comments
 (0)