Skip to content

Commit 6edd3f1

Browse files
gavinkingsebersole
authored andcommitted
HHH-19364 snappier naming
1 parent 0ebc386 commit 6edd3f1

File tree

9 files changed

+74
-72
lines changed

9 files changed

+74
-72
lines changed

documentation/src/main/asciidoc/introduction/Interacting.adoc

+13-13
Original file line numberDiff line numberDiff line change
@@ -1063,16 +1063,16 @@ var selection =
10631063
10641064
// add programmatic restrictions:
10651065
if (titlePattern != null)
1066-
selection.addRestriction(Restriction.like(Book_.title, namePattern));
1066+
selection.restrict(Restriction.like(Book_.title, namePattern));
10671067
if (isbns != null && !isbns.isEmpty())
1068-
selection.addRestriction(Restriction.in(Book_.isbn, isbns));
1068+
selection.restrict(Restriction.in(Book_.isbn, isbns));
10691069
10701070
// add programmatic ordering:
1071-
if (orderByTitle) selection.addOrdering(Order.asc(Book_.title));
1072-
if (orderByIsbn) selection.addOrdering(Order.asc(Book_.isbn));
1071+
if (orderByTitle) selection.sort(Order.asc(Book_.title));
1072+
if (orderByIsbn) selection.sort(Order.asc(Book_.isbn));
10731073
10741074
// add programmatic association fetching:
1075-
if (fetchPublisher) selection.addFetching(Path.from(Book.class).to(Book_.publisher));
1075+
if (fetchPublisher) selection.fetch(Path.from(Book.class).to(Book_.publisher));
10761076
10771077
// execute the query in the given session:
10781078
List<Book> matchingBooks = selection.createQuery(session).getResultList();
@@ -1090,10 +1090,10 @@ We need the following methods of link:{doc-javadoc-url}org/hibernate/query/progr
10901090
|===
10911091
| Method name | Purpose
10921092

1093-
| `addRestriction()` | Add a restriction on the query results
1094-
| `setOrder()`, `addOrder()` | Specify how the query results should be ordered
1095-
| `addFetching()` | Add a fetched association
1096-
| `addAugmentation()` | Add a custom function which directly manipulates the query
1093+
| `restrict()` | Add a `Restriction` on the query results
1094+
| `sort()`, `resort()` | Specify how the query results should be ordered
1095+
| `fetch()` | Add a fetched association `Path`
1096+
| `augment()` | Add a custom function which directly manipulates the query
10971097
|===
10981098

10991099
Alternatively, `Restriction` and `Order` can be used with <<paging-and-ordering,generated query or finder methods>>, and even with link:{doc-data-repositories-url}[Jakarta Data repositories].
@@ -1104,9 +1104,9 @@ The interface link:{doc-javadoc-url}org/hibernate/query/restriction/Path.html[`P
11041104
----
11051105
List<Book> booksForPublisher =
11061106
SelectionSpecification.create(Book.class)
1107-
.addRestriction(Path.from(Book.class).to(Book_.publisher).to(Publisher_.name)
1107+
.restrict(Path.from(Book.class).to(Book_.publisher).to(Publisher_.name)
11081108
.equalTo(publisherName))
1109-
.addFetching(Path.from(Book.class).to(Book_.publisher))
1109+
.fetch(Path.from(Book.class).to(Book_.publisher))
11101110
.createQuery(session)
11111111
.getResultList();
11121112
----
@@ -1117,7 +1117,7 @@ When `Restriction`, `Path`, and `Order` aren't expressive enough, we can _augmen
11171117
----
11181118
var books =
11191119
SelectionSpecification.create(Book.class)
1120-
.addAugmentation((builder, query, book) ->
1120+
.augment((builder, query, book) ->
11211121
// augment the query via JPA Criteria API
11221122
query.where(builder.like(book.get(Book_.title), titlePattern)))
11231123
.orderBy(builder.asc(book.get(Book_.isbn)))
@@ -1131,7 +1131,7 @@ For really advanced cases, `addAugmentation()` works quite nicely with <<criteri
11311131
----
11321132
var books =
11331133
SelectionSpecification.create(Book.class)
1134-
.addAugmentation((builder, query, book) ->
1134+
.augment((builder, query, book) ->
11351135
// eliminate explicit references to 'builder'
11361136
new CriteriaDefinition<>(query) {{
11371137
where(like(entity.get(BasicEntity_.title), titlePattern),

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
* Specialization of {@link QuerySpecification} for programmatic customization of
2222
* {@linkplain MutationQuery mutation queries}.
2323
* <p>
24-
* The method {@link #addRestriction(Restriction)} allows application of additional
24+
* The method {@link #restrict(Restriction)} allows application of additional
2525
* {@linkplain Restriction filtering} to the mutated entity. The static factory
2626
* methods of {@link Restriction} are used to express filtering criteria of various
2727
* kinds.
2828
* <p>
29-
* Once all {@linkplain #addRestriction restrictions} are specified, call
29+
* Once all {@linkplain #restrict restrictions} are specified, call
3030
* {@link #createQuery createQuery()} to obtain an {@linkplain SelectionQuery
3131
* executable mutation query object}.
3232
*
@@ -43,7 +43,7 @@ public interface MutationSpecification<T> extends QuerySpecification<T> {
4343
* Covariant override.
4444
*/
4545
@Override
46-
MutationSpecification<T> addRestriction(Restriction<T> restriction);
46+
MutationSpecification<T> restrict(Restriction<T> restriction);
4747

4848
/**
4949
* A function capable of modifying or augmenting a criteria query.
@@ -62,7 +62,7 @@ interface Augmentation<T> {
6262
*
6363
* @return {@code this} for method chaining.
6464
*/
65-
MutationSpecification<T> addAugmentation(Augmentation<T> augmentation);
65+
MutationSpecification<T> augment(Augmentation<T> augmentation);
6666

6767
/**
6868
* Finalize the building and create the {@linkplain SelectionQuery} instance.
@@ -73,7 +73,7 @@ interface Augmentation<T> {
7373
/**
7474
* Returns a specification reference which can be used to programmatically,
7575
* iteratively build a {@linkplain MutationQuery} based on a base HQL statement,
76-
* allowing the addition of {@linkplain MutationSpecification#addRestriction restrictions}.
76+
* allowing the addition of {@linkplain MutationSpecification#restrict restrictions}.
7777
*
7878
* @param hql The base HQL query (expected to be an {@code update} or {@code delete} query).
7979
* @param mutationTarget The entity which is the target of the mutation.
@@ -91,7 +91,7 @@ static <T> MutationSpecification<T> create(Class<T> mutationTarget, String hql)
9191
/**
9292
* Returns a specification reference which can be used to programmatically,
9393
* iteratively build a {@linkplain MutationQuery} based on the given criteria update,
94-
* allowing the addition of {@linkplain MutationSpecification#addRestriction restrictions}.
94+
* allowing the addition of {@linkplain MutationSpecification#restrict restrictions}.
9595
*
9696
* @param criteriaUpdate The criteria update query
9797
*
@@ -104,7 +104,7 @@ static <T> MutationSpecification<T> create(CriteriaUpdate<T> criteriaUpdate) {
104104
/**
105105
* Returns a specification reference which can be used to programmatically,
106106
* iteratively build a {@linkplain MutationQuery} based on the given criteria delete,
107-
* allowing the addition of {@linkplain MutationSpecification#addRestriction restrictions}.
107+
* allowing the addition of {@linkplain MutationSpecification#restrict restrictions}.
108108
*
109109
* @param criteriaDelete The criteria delete query
110110
*

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public interface QuerySpecification<T> {
3333
*
3434
* @return {@code this} for method chaining.
3535
*/
36-
QuerySpecification<T> addRestriction(Restriction<T> restriction);
36+
QuerySpecification<T> restrict(Restriction<T> restriction);
3737

3838
/**
3939
* Finalize the building and create executable query instance.

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

+20-19
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,22 @@
2222
* Specialization of {@link QuerySpecification} for programmatic customization of
2323
* {@linkplain SelectionQuery selection queries} with ordering and restriction criteria.
2424
* <ul>
25-
* <li>The method {@link #addRestriction(Restriction)} allows application of additional
25+
* <li>The method {@link #restrict(Restriction)} allows application of additional
2626
* {@linkplain Restriction filtering} to the query results. The static factory methods
2727
* of {@link Restriction} are used to express filtering criteria of various kinds.
2828
* <li>Refinement or replacement of the query sorting criteria is possible via the methods
29-
* {@link #addOrdering(Order)} and {@link #setOrdering(List)}, together with the static
29+
* {@link #sort(Order)} and {@link #resort(List)}, together with the static
3030
* factory methods of {@link Order}.
3131
* </ul>
3232
* <p>
33-
* Once all {@linkplain #addOrdering sorting} and {@linkplain #addRestriction restrictions}
33+
* Once all {@linkplain #sort sorting} and {@linkplain #restrict restrictions}
3434
* are specified, call {@link #createQuery createQuery()} to obtain an
3535
* {@linkplain SelectionQuery executable selection query object}.
3636
* <pre>
3737
* SelectionSpecification.create(Book.class, "from Book where discontinued = false")
38-
* .addRestriction(Restriction.contains(Book_.title, "hibernate", false))
39-
* .setOrdering(Order.desc(Book_.title))
38+
* .restrict(Restriction.contains(Book_.title, "hibernate", false))
39+
* .sort(Order.desc(Book_.title))
40+
* .fetch(Path.from(Book.class).to(Book_publisher))
4041
* .createQuery(session) // obtain a SelectionQuery
4142
* .setPage(Page.first(50))
4243
* .getResultList();
@@ -62,7 +63,7 @@ public interface SelectionSpecification<T> extends QuerySpecification<T> {
6263
*
6364
* @return {@code this} for method chaining.
6465
*/
65-
SelectionSpecification<T> addOrdering(Order<T> order);
66+
SelectionSpecification<T> sort(Order<T> order);
6667

6768
/**
6869
* Sets the ordering for this selection specification.
@@ -73,7 +74,7 @@ public interface SelectionSpecification<T> extends QuerySpecification<T> {
7374
*
7475
* @return {@code this} for method chaining.
7576
*/
76-
SelectionSpecification<T> setOrdering(Order<T> order);
77+
SelectionSpecification<T> resort(Order<T> order);
7778

7879
/**
7980
* Sets the sorting for this selection specification.
@@ -84,13 +85,13 @@ public interface SelectionSpecification<T> extends QuerySpecification<T> {
8485
*
8586
* @return {@code this} for method chaining.
8687
*/
87-
SelectionSpecification<T> setOrdering(List<Order<T>> orders);
88+
SelectionSpecification<T> resort(List<Order<T>> orders);
8889

8990
/**
9091
* Covariant override.
9192
*/
9293
@Override
93-
SelectionSpecification<T> addRestriction(Restriction<T> restriction);
94+
SelectionSpecification<T> restrict(Restriction<T> restriction);
9495

9596
/**
9697
* Add a fetch {@linkplain Path path} to the specification.
@@ -99,7 +100,7 @@ public interface SelectionSpecification<T> extends QuerySpecification<T> {
99100
*
100101
* @return {@code this} for method chaining.
101102
*/
102-
SelectionSpecification<T> addFetching(Path<T,?> fetchPath);
103+
SelectionSpecification<T> fetch(Path<T,?> fetchPath);
103104

104105
/**
105106
* A function capable of modifying or augmenting a criteria query.
@@ -117,7 +118,7 @@ interface Augmentation<T> {
117118
* For example:
118119
* <pre>
119120
* SelectionSpecification.create(Book.class)
120-
* .addAugmentation((builder, query, book) ->
121+
* .augment((builder, query, book) ->
121122
* // augment the query via JPA Criteria API
122123
* query.where(builder.like(book.get(Book_.title), titlePattern)),
123124
* builder.greaterThan(book.get(Book_.pages), minPages))
@@ -130,7 +131,7 @@ interface Augmentation<T> {
130131
* the {@link CriteriaBuilder}.
131132
* <pre>
132133
* SelectionSpecification.create(Book.class)
133-
* .addAugmentation((builder, query, book) ->
134+
* .augment((builder, query, book) ->
134135
* // eliminate explicit references to 'builder'
135136
* new CriteriaDefinition<>(query) {{
136137
* where(like(entity.get(BasicEntity_.title), titlePattern),
@@ -146,7 +147,7 @@ interface Augmentation<T> {
146147
*
147148
* @return {@code this} for method chaining.
148149
*/
149-
SelectionSpecification<T> addAugmentation(Augmentation<T> augmentation);
150+
SelectionSpecification<T> augment(Augmentation<T> augmentation);
150151

151152
/**
152153
* Covariant override.
@@ -157,8 +158,8 @@ interface Augmentation<T> {
157158
/**
158159
* Returns a specification reference which can be used to programmatically,
159160
* iteratively build a {@linkplain SelectionQuery} for the given entity type,
160-
* allowing the addition of {@linkplain SelectionSpecification#addOrdering sorting}
161-
* and {@linkplain SelectionSpecification#addRestriction restrictions}.
161+
* allowing the addition of {@linkplain SelectionSpecification#sort sorting}
162+
* and {@linkplain SelectionSpecification#restrict restrictions}.
162163
* This is effectively the same as calling {@linkplain #create(Class, String)}
163164
* with {@code "from {rootEntityType}"} as the HQL.
164165
*
@@ -174,8 +175,8 @@ static <T> SelectionSpecification<T> create(Class<T> rootEntityType) {
174175
/**
175176
* Returns a specification reference which can be used to programmatically,
176177
* iteratively build a {@linkplain SelectionQuery} based on a base HQL statement,
177-
* allowing the addition of {@linkplain SelectionSpecification#addOrdering sorting}
178-
* and {@linkplain SelectionSpecification#addRestriction restrictions}.
178+
* allowing the addition of {@linkplain SelectionSpecification#sort sorting}
179+
* and {@linkplain SelectionSpecification#restrict restrictions}.
179180
*
180181
* @param hql The base HQL query.
181182
* @param resultType The result type which will ultimately be returned from the {@linkplain SelectionQuery}
@@ -193,8 +194,8 @@ static <T> SelectionSpecification<T> create(Class<T> resultType, String hql) {
193194
/**
194195
* Returns a specification reference which can be used to programmatically,
195196
* iteratively build a {@linkplain SelectionQuery} for the given criteria query,
196-
* allowing the addition of {@linkplain SelectionSpecification#addOrdering sorting}
197-
* and {@linkplain SelectionSpecification#addRestriction restrictions}.
197+
* allowing the addition of {@linkplain SelectionSpecification#sort sorting}
198+
* and {@linkplain SelectionSpecification#restrict restrictions}.
198199
*
199200
* @param criteria The criteria query
200201
*

hibernate-core/src/main/java/org/hibernate/query/programmatic/internal/MutationSpecificationImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public MutationSpecificationImpl(CriteriaDelete<T> criteriaQuery) {
6262
}
6363

6464
@Override
65-
public MutationSpecification<T> addRestriction(Restriction<T> restriction) {
65+
public MutationSpecification<T> restrict(Restriction<T> restriction) {
6666
specifications.add( (sqmStatement, mutationTargetRoot) -> {
6767
final SqmPredicate sqmPredicate = (SqmPredicate) restriction.toPredicate(
6868
mutationTargetRoot,
@@ -74,7 +74,7 @@ public MutationSpecification<T> addRestriction(Restriction<T> restriction) {
7474
}
7575

7676
@Override
77-
public MutationSpecification<T> addAugmentation(Augmentation<T> augmentation) {
77+
public MutationSpecification<T> augment(Augmentation<T> augmentation) {
7878
specifications.add( (sqmStatement, mutationTargetRoot) ->
7979
augmentation.augment( sqmStatement.nodeBuilder(), sqmStatement, mutationTargetRoot ) );
8080
return this;

hibernate-core/src/main/java/org/hibernate/query/programmatic/internal/SelectionSpecificationImpl.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public SelectionSpecificationImpl(CriteriaQuery<T> criteriaQuery) {
6464
}
6565

6666
@Override
67-
public SelectionSpecification<T> addRestriction(Restriction<T> restriction) {
67+
public SelectionSpecification<T> restrict(Restriction<T> restriction) {
6868
specifications.add( (sqmStatement, root) -> {
6969
final SqmPredicate sqmPredicate = SqmUtil.restriction( sqmStatement, resultType, restriction );
7070
sqmStatement.getQuerySpec().applyPredicate( sqmPredicate );
@@ -73,28 +73,28 @@ public SelectionSpecification<T> addRestriction(Restriction<T> restriction) {
7373
}
7474

7575
@Override
76-
public SelectionSpecification<T> addAugmentation(Augmentation<T> augmentation) {
76+
public SelectionSpecification<T> augment(Augmentation<T> augmentation) {
7777
specifications.add( (sqmStatement, root) ->
7878
augmentation.augment( sqmStatement.nodeBuilder(), sqmStatement, root ) );
7979
return this;
8080
}
8181

8282
@Override
83-
public SelectionSpecification<T> addFetching(Path<T, ?> fetchPath) {
83+
public SelectionSpecification<T> fetch(Path<T, ?> fetchPath) {
8484
specifications.add( (sqmStatement, root) -> fetchPath.fetch( root ) );
8585
return this;
8686
}
8787

8888
@Override
89-
public SelectionSpecification<T> addOrdering(Order<T> order) {
89+
public SelectionSpecification<T> sort(Order<T> order) {
9090
specifications.add( (sqmStatement, root) -> {
9191
addOrder( order, sqmStatement );
9292
} );
9393
return this;
9494
}
9595

9696
@Override
97-
public final SelectionSpecification<T> setOrdering(Order<T> order) {
97+
public final SelectionSpecification<T> resort(Order<T> order) {
9898
specifications.add( (sqmStatement, root) -> {
9999
sqmStatement.getQuerySpec().setOrderByClause( new SqmOrderByClause() );
100100
addOrder( order, sqmStatement );
@@ -103,7 +103,7 @@ public final SelectionSpecification<T> setOrdering(Order<T> order) {
103103
}
104104

105105
@Override
106-
public final SelectionSpecification<T> setOrdering(List<Order<T>> orders) {
106+
public final SelectionSpecification<T> resort(List<Order<T>> orders) {
107107
specifications.add( (sqmStatement, root) -> {
108108
sqmStatement.getQuerySpec().setOrderByClause( new SqmOrderByClause() );
109109
orders.forEach( order -> addOrder( order, sqmStatement ) );

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
* the root entity type of the query.
2020
* <pre>
2121
* SelectionSpecification.create(Book.class)
22-
* .addRestriction(from(Book.class).to(Book_.publisher).to(Publisher_.name)
22+
* .restrict(from(Book.class).to(Book_.publisher).to(Publisher_.name)
2323
* .equalTo("Manning"))
24+
* .fetch(from(Book.class).to(Book_.publisher))
2425
* .createQuery(session)
2526
* .getResultList()
2627
* </pre>

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
* {@link SelectionQuery#addRestriction(Restriction)}.
2525
* <pre>
2626
* SelectionSpecification.create(Book.class)
27-
* .addRestriction(Restriction.like(Book_.title, "%Hibernate%", false))
28-
* .addRestriction(Restriction.greaterThan(Book_.pages, 100))
29-
* .setOrder(Order.desc(Book_.title))
27+
* .restrict(Restriction.like(Book_.title, "%Hibernate%", false))
28+
* .restrict(Restriction.greaterThan(Book_.pages, 100))
29+
* .sort(Order.desc(Book_.title))
3030
* .createQuery(session)
3131
* .getResultList();
3232
* </pre>
@@ -50,7 +50,7 @@
5050
*
5151
* @see org.hibernate.query.programmatic.SelectionSpecification
5252
* @see org.hibernate.query.programmatic.MutationSpecification
53-
* @see org.hibernate.query.programmatic.QuerySpecification#addRestriction(Restriction)
53+
* @see org.hibernate.query.programmatic.QuerySpecification#restrict(Restriction)
5454
*
5555
* @see Path
5656
* @see Order

0 commit comments

Comments
 (0)