Skip to content

Commit ea06673

Browse files
committed
HHH-19364 call mutation of the specification "Augmentation"
1 parent d7a2071 commit ea06673

File tree

5 files changed

+35
-11
lines changed

5 files changed

+35
-11
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,24 @@ public interface MutationSpecification<T> extends QuerySpecification<T> {
4545
@Override
4646
MutationSpecification<T> addRestriction(Restriction<T> restriction);
4747

48+
/**
49+
* A function capable of modifying or augmenting a criteria query.
50+
*
51+
* @param <T> The target entity type
52+
*/
4853
@FunctionalInterface
49-
interface Mutator<T> {
50-
void mutate(CriteriaBuilder builder, CommonAbstractCriteria query, Root<T> mutationTarget);
54+
interface Augmentation<T> {
55+
void augment(CriteriaBuilder builder, CommonAbstractCriteria query, Root<T> mutationTarget);
5156
}
5257

53-
MutationSpecification<T> mutate(Mutator<T> mutation);
58+
/**
59+
* Add an {@linkplain Augmentation augmentation} to the specification.
60+
*
61+
* @param augmentation A function capable of modifying or augmenting a criteria query.
62+
*
63+
* @return {@code this} for method chaining.
64+
*/
65+
MutationSpecification<T> addAugmentation(Augmentation<T> augmentation);
5466

5567
/**
5668
* Finalize the building and create the {@linkplain SelectionQuery} instance.

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,24 @@ public interface SelectionSpecification<T> extends QuerySpecification<T> {
101101
*/
102102
SelectionSpecification<T> addFetching(Path<T,?> fetchPath);
103103

104+
/**
105+
* A function capable of modifying or augmenting a criteria query.
106+
*
107+
* @param <T> The root entity type
108+
*/
104109
@FunctionalInterface
105-
interface Mutator<T> {
106-
void mutate(CriteriaBuilder builder, CriteriaQuery<T> query, Root<T> root);
110+
interface Augmentation<T> {
111+
void augment(CriteriaBuilder builder, CriteriaQuery<T> query, Root<T> root);
107112
}
108113

109-
SelectionSpecification<T> mutate(Mutator<T> mutation);
114+
/**
115+
* Add an {@linkplain Augmentation augmentation} to the specification.
116+
*
117+
* @param augmentation A function capable of modifying or augmenting a criteria query.
118+
*
119+
* @return {@code this} for method chaining.
120+
*/
121+
SelectionSpecification<T> addAugmentation(Augmentation<T> augmentation);
110122

111123
/**
112124
* Covariant override.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ public MutationSpecification<T> addRestriction(Restriction<T> restriction) {
7474
}
7575

7676
@Override
77-
public MutationSpecification<T> mutate(Mutator<T> mutation) {
77+
public MutationSpecification<T> addAugmentation(Augmentation<T> augmentation) {
7878
specifications.add( (sqmStatement, mutationTargetRoot) ->
79-
mutation.mutate( sqmStatement.nodeBuilder(), sqmStatement, mutationTargetRoot ) );
79+
augmentation.augment( sqmStatement.nodeBuilder(), sqmStatement, mutationTargetRoot ) );
8080
return this;
8181
}
8282

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ public SelectionSpecification<T> addRestriction(Restriction<T> restriction) {
7373
}
7474

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

hibernate-core/src/test/java/org/hibernate/orm/test/query/dynamic/SimpleQuerySpecificationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ void testCriteriaFormWithMutation(SessionFactoryScope factoryScope) {
201201
factoryScope.inTransaction( (session) -> {
202202
sqlCollector.clear();
203203
SelectionSpecification.create( BasicEntity.class )
204-
.mutate( (builder, query, entity) -> query.where( builder.like( entity.get( BasicEntity_.name ), "%" ) ) )
204+
.addAugmentation( (builder, query, entity) -> query.where( builder.like( entity.get( BasicEntity_.name ), "%" ) ) )
205205
.addOrdering( Order.asc( BasicEntity_.position ) )
206206
.createQuery( session )
207207
.getResultList();

0 commit comments

Comments
 (0)