Skip to content

Commit 68b9ecf

Browse files
committed
update the javadoc after the addition of QuerySpecification
1 parent 58d792e commit 68b9ecf

File tree

7 files changed

+63
-21
lines changed

7 files changed

+63
-21
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,8 @@ public interface QueryProducer {
513513
*
514514
* @throws IllegalSelectQueryException The given HQL is expected to be a {@code select} query. This method will
515515
* throw an exception if not.
516+
*
517+
* @since 7.0
516518
*/
517519
@Incubating
518520
<T> SelectionSpecification<T> createSelectionSpecification(String hql, Class<T> resultType)
@@ -530,6 +532,8 @@ <T> SelectionSpecification<T> createSelectionSpecification(String hql, Class<T>
530532
*
531533
* @param <T> The entity type which is the root of the query.
532534
* {@code resultType} and {@code <T>} are both expected to refer to a singular query root.
535+
*
536+
* @since 7.0
533537
*/
534538
@Incubating
535539
<T> SelectionSpecification<T> createSelectionSpecification(Class<T> rootEntityType);
@@ -547,6 +551,8 @@ <T> SelectionSpecification<T> createSelectionSpecification(String hql, Class<T>
547551
*
548552
* @throws IllegalMutationQueryException Only {@code update} and {@code delete} are supported;
549553
* this method will throw an exception if the given HQL query is not an {@code update} or {@code delete}.
554+
*
555+
* @since 7.0
550556
*/
551557
@Incubating
552558
<T> MutationSpecification<T> createMutationSpecification(String hql, Class<T> mutationTarget)

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@
100100
* every {@link jakarta.persistence.FetchType#EAGER eager} {@code @ManyToOne} or
101101
* {@code @OneToOne} association belonging to an entity returned by the query.
102102
* <p>
103-
* The method {@link #addRestriction(Restriction)} allows application of additional
104-
* {@linkplain Restriction filtering} to the query results. The static factory
105-
* methods of {@code Restriction} are used to express filtering criteria of various
106-
* kinds.
107-
* <p>
108103
* Finally, two alternative approaches to pagination are available:
109104
* <ol>
110105
* <li>
@@ -114,10 +109,9 @@
114109
* {@link #setFirstResult(int)} and {@link #setMaxResults(int)}.
115110
* <pre>
116111
* session.createSelectionQuery("from Book", Book.class)
117-
* .addRestriction(Restriction.contains(Book_.title, "hibernate", false))
118112
* .setOrder(Order.desc(Book_.title))
119113
* .setPage(Page.first(50))
120-
* .getResultList() );
114+
* .getResultList();
121115
* </pre>
122116
* <li>
123117
* On the other hand, {@link KeyedPage} and {@link KeyedResultList}, along with

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,23 @@
1111
import org.hibernate.query.restriction.Restriction;
1212

1313
/**
14-
* Specialization of QuerySpecification for building
14+
* Specialization of {@link QuerySpecification} for programmatic customization of
1515
* {@linkplain MutationQuery mutation queries}.
16-
* Once all {@linkplain #addRestriction restrictions} are defined, call
17-
* {@linkplain #createQuery()} to obtain the executable form.
16+
* <p>
17+
* The method {@link #addRestriction(Restriction)} allows application of additional
18+
* {@linkplain Restriction filtering} to the mutated entity. The static factory
19+
* methods of {@link Restriction} are used to express filtering criteria of various
20+
* kinds.
21+
* <p>
22+
* Once all {@linkplain #addRestriction restrictions} are specified, call
23+
* {@linkplain #createQuery()} to obtain an {@linkplain SelectionQuery an
24+
* executable mutation query object}.
1825
*
1926
* @param <T> The entity type which is the target of the mutation.
2027
*
2128
* @author Steve Ebersole
29+
*
30+
* @since 7.0
2231
*/
2332
@Incubating
2433
public interface MutationSpecification<T> extends QuerySpecification<T> {
@@ -38,5 +47,6 @@ default Root<T> getMutationTarget() {
3847
/**
3948
* Finalize the building and create the {@linkplain SelectionQuery} instance.
4049
*/
50+
@Override
4151
MutationQuery createQuery();
4252
}

hibernate-core/src/main/java/org/hibernate/query/programmatic/QuerySpecification.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* @apiNote Query specifications only support a {@linkplain #getRoot() single root}.
1818
*
1919
* @author Steve Ebersole
20+
*
21+
* @since 7.0
2022
*/
2123
@Incubating
2224
public interface QuerySpecification<T> {

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

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,40 @@
1414
import java.util.List;
1515

1616
/**
17-
* Specialization of QuerySpecification for building
18-
* {@linkplain SelectionQuery selection queries} supporting ordering
19-
* in addition to restrictions.
17+
* Specialization of {@link QuerySpecification} for programmatic customization of
18+
* {@linkplain SelectionQuery selection queries} with ordering and restriction criteria.
19+
* <ul>
20+
* <li>The method {@link #addRestriction(Restriction)} allows application of additional
21+
* {@linkplain Restriction filtering} to the query results. The static factory methods
22+
* of {@link Restriction} are used to express filtering criteria of various kinds.
23+
* <li>Refinement or replacement of the query sorting criteria is possible via the methods
24+
* {@link #addOrdering(Order)} and {@link #setOrdering(List)}, together with the static
25+
* factory methods of {@link Order}.
26+
* </ul>
27+
* <p>
2028
* Once all {@linkplain #addOrdering sorting} and {@linkplain #addRestriction restrictions}
21-
* are defined, call {@linkplain #createQuery()} to obtain the executable form.
29+
* are specified, call {@linkplain #createQuery()} to obtain an {@linkplain SelectionQuery
30+
* executable selection query object}.
31+
* <pre>
32+
* session.createSelectionSpecification("from Book", Book.class)
33+
* .addRestriction(Restriction.contains(Book_.title, "hibernate", false))
34+
* .setOrdering(Order.desc(Book_.title))
35+
* .createQuery() // obtain a SelectionQuery
36+
* .setPage(Page.first(50))
37+
* .getResultList();
38+
* </pre>
39+
* <p>
40+
* A {@code SelectionSpecification} always represents a query which returns a singe root
41+
* entity. The restriction and ordering criteria are interpreted as applying to the field
42+
* and properties of this root entity.
43+
*
44+
* @param <T> The entity type returned by the query
2245
*
2346
* @see QueryProducer#createSelectionSpecification(String, Class)
2447
*
2548
* @author Steve Ebersole
49+
*
50+
* @since 7.0
2651
*/
2752
@Incubating
2853
public interface SelectionSpecification<T> extends QuerySpecification<T> {
@@ -73,5 +98,6 @@ public interface SelectionSpecification<T> extends QuerySpecification<T> {
7398
/**
7499
* Covariant override.
75100
*/
101+
@Override
76102
SelectionQuery<T> createQuery();
77103
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
* A compound path is a sequence of attribute references rooted at
1818
* the root entity type of the query.
1919
* <pre>
20-
* session.createSelectionQuery("from Book", Book.class)
20+
* session.createSelectionSpecification("from Book", Book.class)
2121
* .addRestriction(from(Book.class).to(Book_.publisher).to(Publisher_.name)
2222
* .equalTo("Manning"))
23+
* .createQuery()
2324
* .getResultList()
2425
* </pre>
2526
* A compound path-based restriction has the same semantics as the

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
import java.util.List;
2020

2121
/**
22-
* A rule for restricting query results.
23-
* <p>
24-
* This allows restrictions to be added to a {@link SelectionQuery} by calling
22+
* A rule for restricting query results. This allows restrictions to be added to
23+
* a {@link org.hibernate.query.programmatic.SelectionSpecification} by calling
2524
* {@link SelectionQuery#addRestriction(Restriction)}.
2625
* <pre>
27-
* session.createSelectionQuery("from Book", Book.class)
26+
* session.createSelectionSpecification("from Book", Book.class)
2827
* .addRestriction(Restriction.like(Book_.title, "%Hibernate%", false))
2928
* .addRestriction(Restriction.greaterThan(Book_.pages, 100))
3029
* .setOrder(Order.desc(Book_.title))
31-
* .getResultList() );
30+
* .createQuery()
31+
* .getResultList();
3232
* </pre>
3333
* <p>
3434
* Each restriction pairs an {@linkplain SingularAttribute attribute} of the
@@ -48,7 +48,10 @@
4848
* is used by Hibernate Data Repositories to implement Jakarta Data
4949
* query methods.
5050
*
51-
* @see SelectionQuery#addRestriction(Restriction)
51+
* @see org.hibernate.query.programmatic.SelectionSpecification
52+
* @see org.hibernate.query.programmatic.MutationSpecification
53+
* @see org.hibernate.query.programmatic.QuerySpecification#addRestriction(Restriction)
54+
*
5255
* @see Path
5356
* @see Order
5457
*

0 commit comments

Comments
 (0)