Skip to content

Commit 825631a

Browse files
committed
HHH-19364 final touches to jdoc before release
1 parent f5edcd9 commit 825631a

File tree

5 files changed

+39
-32
lines changed

5 files changed

+39
-32
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
import static org.hibernate.query.SortDirection.DESCENDING;
1616

1717
/**
18-
* A rule for sorting a query result set.
19-
* <p>
20-
* This is a convenience class which allows query result ordering rules to be
21-
* passed around the system before being applied to a {@link Query} by calling
22-
* {@link org.hibernate.query.specification.SelectionSpecification#sort(Order)}.
18+
* A rule for sorting a query result set. This allows query result ordering
19+
* rules to be passed around the system before being applied to a
20+
* {@link org.hibernate.query.specification.QuerySpecification} by calling
21+
* {@link org.hibernate.query.specification.SelectionSpecification#sort(Order)
22+
* sort()}.
2323
* <pre>
2424
* SelectionSpecification.create(Book.class,
2525
* "from Book b join b.authors a where a.name = :name")
@@ -30,7 +30,8 @@
3030
* </pre>
3131
* <p>
3232
* {@code Order}s may be stacked using {@link List#of} and
33-
* {@link org.hibernate.query.specification.SelectionSpecification#resort(List)}.
33+
* {@link org.hibernate.query.specification.SelectionSpecification#resort(List)
34+
* resort()}.
3435
* <pre>
3536
* SelectionSpecification.create(Book.class,
3637
* "from Book b join b.authors a where a.name = :name")

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,16 @@
9999
* every {@link jakarta.persistence.FetchType#EAGER eager} {@code @ManyToOne} or
100100
* {@code @OneToOne} association belonging to an entity returned by the query.
101101
* <p>
102-
* Finally, two alternative approaches to pagination are available:
102+
* Finally, three alternative approaches to pagination are available:
103103
* <ol>
104104
* <li>
105-
* The operations and {@link #setOrder(List)} and {@link #setPage(Page)}, together
106-
* with {@link Order} and {@link Page}, provide a streamlined API for offset-based
107-
* pagination, at a slightly higher semantic level than the ancient but dependable
108-
* {@link #setFirstResult(int)} and {@link #setMaxResults(int)}.
109-
* <pre>
110-
* session.createSelectionQuery("from Book", Book.class)
111-
* .setOrder(Order.desc(Book_.title))
112-
* .setPage(Page.first(50))
113-
* .getResultList();
114-
* </pre>
105+
* The ancient but dependable operations {@link #setFirstResult(int)} and
106+
* {@link #setMaxResults(int)} are the standard approach blessed by the JPA
107+
* specification.
108+
* <li>
109+
* {@link org.hibernate.query.specification.SelectionSpecification SelectionSpecification}
110+
* and {@link #setPage(Page)}, together with {@link Order} and {@link Page}, provide
111+
* a streamlined API for offset-based pagination, at a slightly higher semantic level.
115112
* <li>
116113
* On the other hand, {@link KeyedPage} and {@link KeyedResultList}, along with
117114
* {@link #getKeyedResultList(KeyedPage)}, provide for <em>key-based pagination</em>,

hibernate-core/src/main/java/org/hibernate/query/restriction/Restriction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919

2020
/**
2121
* A rule for restricting query results. This allows restrictions to be added to
22-
* a {@link org.hibernate.query.specification.SelectionSpecification} by calling
23-
* {@link org.hibernate.query.specification.SelectionSpecification#restrict(Restriction)}.
22+
* a {@link org.hibernate.query.specification.QuerySpecification} by calling
23+
* {@link org.hibernate.query.specification.QuerySpecification#restrict(Restriction)
24+
* restrict()}.
2425
* <pre>
2526
* SelectionSpecification.create(Book.class)
2627
* .restrict(Restriction.like(Book_.title, "%Hibernate%", false))

hibernate-core/src/main/java/org/hibernate/query/specification/MutationSpecification.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
* {@linkplain Restriction filtering} to the mutated entity. The static factory
2828
* methods of {@link Restriction} are used to express filtering criteria of various
2929
* kinds.
30+
* <pre>
31+
* MutationSpecification.create(Book.class, "delete from Book")
32+
* .restrict(Restriction.lessThan(Book_.publicationDate,
33+
* LocalDate.ofYearDay(2000,1)))
34+
* .createQuery(session)
35+
* .executeUpdate();
36+
* </pre>
3037
* <p>
3138
* Once all {@linkplain #restrict restrictions} are specified, call
3239
* {@link #createQuery createQuery()} to obtain an {@linkplain MutationQuery
@@ -41,9 +48,6 @@
4148
@Incubating
4249
public interface MutationSpecification<T> extends QuerySpecification<T> {
4350

44-
/**
45-
* Covariant override.
46-
*/
4751
@Override
4852
MutationSpecification<T> restrict(Restriction<? super T> restriction);
4953

hibernate-core/src/main/java/org/hibernate/query/specification/SelectionSpecification.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.hibernate.StatelessSession;
1616
import org.hibernate.query.IllegalSelectQueryException;
1717
import org.hibernate.query.Order;
18+
import org.hibernate.query.Page;
1819
import org.hibernate.query.SelectionQuery;
1920
import org.hibernate.query.specification.internal.SelectionSpecificationImpl;
2021
import org.hibernate.query.restriction.Path;
@@ -40,7 +41,8 @@
4041
* are specified, call {@link #createQuery createQuery()} to obtain an
4142
* {@linkplain SelectionQuery executable selection query object}.
4243
* <pre>
43-
* SelectionSpecification.create(Book.class, "from Book where discontinued = false")
44+
* SelectionSpecification.create(Book.class,
45+
* "from Book where discontinued = false")
4446
* .restrict(Restriction.contains(Book_.title, "hibernate", false))
4547
* .sort(Order.desc(Book_.title))
4648
* .fetch(Path.from(Book.class).to(Book_publisher))
@@ -52,6 +54,17 @@
5254
* A {@code SelectionSpecification} always represents a query which returns a singe root
5355
* entity. The restriction and ordering criteria are interpreted as applying to the field
5456
* and properties of this root entity.
57+
* <p>
58+
* This interface, together with {@link Order} and {@link Page}, provides a streamlined
59+
* API for offset-based pagination. For example, given a list of {@code Order}s in
60+
* {@code orderList}, and the {@code currentPage}, we may write:
61+
* <pre>
62+
* SelectionSpecification.create(Book.class, "from Book where ... ")
63+
* .resort(orderList)
64+
* .createQuery(session)
65+
* .setPage(currentPage)
66+
* .getResultList();
67+
* </pre>
5568
*
5669
* @param <T> The entity type returned by the query
5770
*
@@ -93,9 +106,6 @@ public interface SelectionSpecification<T> extends QuerySpecification<T> {
93106
*/
94107
SelectionSpecification<T> resort(List<Order<? super T>> orders);
95108

96-
/**
97-
* Covariant override.
98-
*/
99109
@Override
100110
SelectionSpecification<T> restrict(Restriction<? super T> restriction);
101111

@@ -155,15 +165,9 @@ interface Augmentation<T> {
155165
*/
156166
SelectionSpecification<T> augment(Augmentation<T> augmentation);
157167

158-
/**
159-
* Covariant override.
160-
*/
161168
@Override
162169
SelectionQuery<T> createQuery(Session session);
163170

164-
/**
165-
* Covariant override.
166-
*/
167171
@Override
168172
SelectionQuery<T> createQuery(StatelessSession session);
169173

0 commit comments

Comments
 (0)