diff --git a/documentation/src/main/asciidoc/introduction/Interacting.adoc b/documentation/src/main/asciidoc/introduction/Interacting.adoc index 424c2c557ae5..2122819039b2 100644 --- a/documentation/src/main/asciidoc/introduction/Interacting.adoc +++ b/documentation/src/main/asciidoc/introduction/Interacting.adoc @@ -1061,16 +1061,16 @@ var selection = // add programmatic restrictions: if (titlePattern != null) - selection.addRestriction(Restriction.like(Book_.title, namePattern)); + selection.restrict(Restriction.like(Book_.title, namePattern)); if (isbns != null && !isbns.isEmpty()) - selection.addRestriction(Restriction.in(Book_.isbn, isbns)); + selection.restrict(Restriction.in(Book_.isbn, isbns)); // add programmatic ordering: -if (orderByTitle) selection.addOrdering(Order.asc(Book_.title)); -if (orderByIsbn) selection.addOrdering(Order.asc(Book_.isbn)); +if (orderByTitle) selection.sort(Order.asc(Book_.title)); +if (orderByIsbn) selection.sort(Order.asc(Book_.isbn)); // add programmatic association fetching: -if (fetchPublisher) selection.addFetching(Path.from(Book.class).to(Book_.publisher)); +if (fetchPublisher) selection.fetch(Path.from(Book.class).to(Book_.publisher)); // execute the query in the given session: List matchingBooks = selection.createQuery(session).getResultList(); @@ -1088,10 +1088,10 @@ We need the following methods of link:{doc-javadoc-url}org/hibernate/query/progr |=== | Method name | Purpose -| `addRestriction()` | Add a restriction on the query results -| `setOrder()`, `addOrder()` | Specify how the query results should be ordered -| `addFetching()` | Add a fetched association -| `addAugmentation()` | Add a custom function which directly manipulates the query +| `restrict()` | Add a `Restriction` on the query results +| `sort()`, `resort()` | Specify how the query results should be ordered +| `fetch()` | Add a fetched association `Path` +| `augment()` | Add a custom function which directly manipulates the query |=== Alternatively, `Restriction` and `Order` can be used with <>, and even with link:{doc-data-repositories-url}[Jakarta Data repositories]. @@ -1102,9 +1102,9 @@ The interface link:{doc-javadoc-url}org/hibernate/query/restriction/Path.html[`P ---- List booksForPublisher = SelectionSpecification.create(Book.class) - .addRestriction(Path.from(Book.class).to(Book_.publisher).to(Publisher_.name) + .restrict(Path.from(Book.class).to(Book_.publisher).to(Publisher_.name) .equalTo(publisherName)) - .addFetching(Path.from(Book.class).to(Book_.publisher)) + .fetch(Path.from(Book.class).to(Book_.publisher)) .createQuery(session) .getResultList(); ---- @@ -1115,7 +1115,7 @@ When `Restriction`, `Path`, and `Order` aren't expressive enough, we can _augmen ---- var books = SelectionSpecification.create(Book.class) - .addAugmentation((builder, query, book) -> + .augment((builder, query, book) -> // augment the query via JPA Criteria API query.where(builder.like(book.get(Book_.title), titlePattern))) .orderBy(builder.asc(book.get(Book_.isbn))) @@ -1129,7 +1129,7 @@ For really advanced cases, `addAugmentation()` works quite nicely with < + .augment((builder, query, book) -> // eliminate explicit references to 'builder' new CriteriaDefinition<>(query) {{ where(like(entity.get(BasicEntity_.title), titlePattern), diff --git a/hibernate-core/src/main/java/org/hibernate/query/programmatic/MutationSpecification.java b/hibernate-core/src/main/java/org/hibernate/query/programmatic/MutationSpecification.java index 417bee3d1400..e7d436c73c19 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/programmatic/MutationSpecification.java +++ b/hibernate-core/src/main/java/org/hibernate/query/programmatic/MutationSpecification.java @@ -21,12 +21,12 @@ * Specialization of {@link QuerySpecification} for programmatic customization of * {@linkplain MutationQuery mutation queries}. *

- * The method {@link #addRestriction(Restriction)} allows application of additional + * The method {@link #restrict(Restriction)} allows application of additional * {@linkplain Restriction filtering} to the mutated entity. The static factory * methods of {@link Restriction} are used to express filtering criteria of various * kinds. *

- * Once all {@linkplain #addRestriction restrictions} are specified, call + * Once all {@linkplain #restrict restrictions} are specified, call * {@link #createQuery createQuery()} to obtain an {@linkplain SelectionQuery * executable mutation query object}. * @@ -43,7 +43,7 @@ public interface MutationSpecification extends QuerySpecification { * Covariant override. */ @Override - MutationSpecification addRestriction(Restriction restriction); + MutationSpecification restrict(Restriction restriction); /** * A function capable of modifying or augmenting a criteria query. @@ -62,7 +62,7 @@ interface Augmentation { * * @return {@code this} for method chaining. */ - MutationSpecification addAugmentation(Augmentation augmentation); + MutationSpecification augment(Augmentation augmentation); /** * Finalize the building and create the {@linkplain SelectionQuery} instance. @@ -73,7 +73,7 @@ interface Augmentation { /** * Returns a specification reference which can be used to programmatically, * iteratively build a {@linkplain MutationQuery} based on a base HQL statement, - * allowing the addition of {@linkplain MutationSpecification#addRestriction restrictions}. + * allowing the addition of {@linkplain MutationSpecification#restrict restrictions}. * * @param hql The base HQL query (expected to be an {@code update} or {@code delete} query). * @param mutationTarget The entity which is the target of the mutation. @@ -91,7 +91,7 @@ static MutationSpecification create(Class mutationTarget, String hql) /** * Returns a specification reference which can be used to programmatically, * iteratively build a {@linkplain MutationQuery} based on the given criteria update, - * allowing the addition of {@linkplain MutationSpecification#addRestriction restrictions}. + * allowing the addition of {@linkplain MutationSpecification#restrict restrictions}. * * @param criteriaUpdate The criteria update query * @@ -104,7 +104,7 @@ static MutationSpecification create(CriteriaUpdate criteriaUpdate) { /** * Returns a specification reference which can be used to programmatically, * iteratively build a {@linkplain MutationQuery} based on the given criteria delete, - * allowing the addition of {@linkplain MutationSpecification#addRestriction restrictions}. + * allowing the addition of {@linkplain MutationSpecification#restrict restrictions}. * * @param criteriaDelete The criteria delete query * diff --git a/hibernate-core/src/main/java/org/hibernate/query/programmatic/QuerySpecification.java b/hibernate-core/src/main/java/org/hibernate/query/programmatic/QuerySpecification.java index ab7e23066abd..eccbdc27dc08 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/programmatic/QuerySpecification.java +++ b/hibernate-core/src/main/java/org/hibernate/query/programmatic/QuerySpecification.java @@ -33,7 +33,7 @@ public interface QuerySpecification { * * @return {@code this} for method chaining. */ - QuerySpecification addRestriction(Restriction restriction); + QuerySpecification restrict(Restriction restriction); /** * Finalize the building and create executable query instance. diff --git a/hibernate-core/src/main/java/org/hibernate/query/programmatic/SelectionSpecification.java b/hibernate-core/src/main/java/org/hibernate/query/programmatic/SelectionSpecification.java index 9b24e3987baa..7ed622d3dc58 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/programmatic/SelectionSpecification.java +++ b/hibernate-core/src/main/java/org/hibernate/query/programmatic/SelectionSpecification.java @@ -22,21 +22,22 @@ * Specialization of {@link QuerySpecification} for programmatic customization of * {@linkplain SelectionQuery selection queries} with ordering and restriction criteria. *

    - *
  • The method {@link #addRestriction(Restriction)} allows application of additional + *
  • The method {@link #restrict(Restriction)} allows application of additional * {@linkplain Restriction filtering} to the query results. The static factory methods * of {@link Restriction} are used to express filtering criteria of various kinds. *
  • Refinement or replacement of the query sorting criteria is possible via the methods - * {@link #addOrdering(Order)} and {@link #setOrdering(List)}, together with the static + * {@link #sort(Order)} and {@link #resort(List)}, together with the static * factory methods of {@link Order}. *
*

- * Once all {@linkplain #addOrdering sorting} and {@linkplain #addRestriction restrictions} + * Once all {@linkplain #sort sorting} and {@linkplain #restrict restrictions} * are specified, call {@link #createQuery createQuery()} to obtain an * {@linkplain SelectionQuery executable selection query object}. *

  * SelectionSpecification.create(Book.class, "from Book where discontinued = false")
- *         .addRestriction(Restriction.contains(Book_.title, "hibernate", false))
- *         .setOrdering(Order.desc(Book_.title))
+ *         .restrict(Restriction.contains(Book_.title, "hibernate", false))
+ *         .sort(Order.desc(Book_.title))
+ *         .fetch(Path.from(Book.class).to(Book_publisher))
  *         .createQuery(session)                       // obtain a SelectionQuery
  *         .setPage(Page.first(50))
  *         .getResultList();
@@ -62,7 +63,7 @@ public interface SelectionSpecification extends QuerySpecification {
 	 *
 	 * @return {@code this} for method chaining.
 	 */
-	SelectionSpecification addOrdering(Order order);
+	SelectionSpecification sort(Order order);
 
 	/**
 	 * Sets the ordering for this selection specification.
@@ -73,7 +74,7 @@ public interface SelectionSpecification extends QuerySpecification {
 	 *
 	 * @return {@code this} for method chaining.
 	 */
-	SelectionSpecification setOrdering(Order order);
+	SelectionSpecification resort(Order order);
 
 	/**
 	 * Sets the sorting for this selection specification.
@@ -84,13 +85,13 @@ public interface SelectionSpecification extends QuerySpecification {
 	 *
 	 * @return {@code this} for method chaining.
 	 */
-	SelectionSpecification setOrdering(List> orders);
+	SelectionSpecification resort(List> orders);
 
 	/**
 	 * Covariant override.
 	 */
 	@Override
-	SelectionSpecification addRestriction(Restriction restriction);
+	SelectionSpecification restrict(Restriction restriction);
 
 	/**
 	 * Add a fetch {@linkplain Path path} to the specification.
@@ -99,7 +100,7 @@ public interface SelectionSpecification extends QuerySpecification {
 	 *
 	 * @return {@code this} for method chaining.
 	 */
-	SelectionSpecification addFetching(Path fetchPath);
+	SelectionSpecification fetch(Path fetchPath);
 
 	/**
 	 * A function capable of modifying or augmenting a criteria query.
@@ -117,7 +118,7 @@ interface Augmentation {
 	 * For example:
 	 * 
 	 * SelectionSpecification.create(Book.class)
-	 *       .addAugmentation((builder, query, book) ->
+	 *       .augment((builder, query, book) ->
 	 *               // augment the query via JPA Criteria API
 	 *               query.where(builder.like(book.get(Book_.title), titlePattern)),
 	 *                           builder.greaterThan(book.get(Book_.pages), minPages))
@@ -130,7 +131,7 @@ interface Augmentation {
 	 * the {@link CriteriaBuilder}.
 	 * 
 	 * SelectionSpecification.create(Book.class)
-	 *       .addAugmentation((builder, query, book) ->
+	 *       .augment((builder, query, book) ->
 	 *           // eliminate explicit references to 'builder'
 	 *           new CriteriaDefinition<>(query) {{
 	 *               where(like(entity.get(BasicEntity_.title), titlePattern),
@@ -146,7 +147,7 @@ interface Augmentation {
 	 *
 	 * @return {@code this} for method chaining.
 	 */
-	SelectionSpecification addAugmentation(Augmentation augmentation);
+	SelectionSpecification augment(Augmentation augmentation);
 
 	/**
 	 * Covariant override.
@@ -157,8 +158,8 @@ interface Augmentation {
 	/**
 	 * Returns a specification reference which can be used to programmatically,
 	 * iteratively build a {@linkplain SelectionQuery} for the given entity type,
-	 * allowing the addition of {@linkplain SelectionSpecification#addOrdering sorting}
-	 * and {@linkplain SelectionSpecification#addRestriction restrictions}.
+	 * allowing the addition of {@linkplain SelectionSpecification#sort sorting}
+	 * and {@linkplain SelectionSpecification#restrict restrictions}.
 	 * This is effectively the same as calling {@linkplain #create(Class, String)}
 	 * with {@code "from {rootEntityType}"} as the HQL.
 	 *
@@ -174,8 +175,8 @@ static  SelectionSpecification create(Class rootEntityType) {
 	/**
 	 * Returns a specification reference which can be used to programmatically,
 	 * iteratively build a {@linkplain SelectionQuery} based on a base HQL statement,
-	 * allowing the addition of {@linkplain SelectionSpecification#addOrdering sorting}
-	 * and {@linkplain SelectionSpecification#addRestriction restrictions}.
+	 * allowing the addition of {@linkplain SelectionSpecification#sort sorting}
+	 * and {@linkplain SelectionSpecification#restrict restrictions}.
 	 *
 	 * @param hql The base HQL query.
 	 * @param resultType The result type which will ultimately be returned from the {@linkplain SelectionQuery}
@@ -193,8 +194,8 @@ static  SelectionSpecification create(Class resultType, String hql) {
 	/**
 	 * Returns a specification reference which can be used to programmatically,
 	 * iteratively build a {@linkplain SelectionQuery} for the given criteria query,
-	 * allowing the addition of {@linkplain SelectionSpecification#addOrdering sorting}
-	 * and {@linkplain SelectionSpecification#addRestriction restrictions}.
+	 * allowing the addition of {@linkplain SelectionSpecification#sort sorting}
+	 * and {@linkplain SelectionSpecification#restrict restrictions}.
 	 *
 	 * @param criteria The criteria query
 	 *
diff --git a/hibernate-core/src/main/java/org/hibernate/query/programmatic/internal/MutationSpecificationImpl.java b/hibernate-core/src/main/java/org/hibernate/query/programmatic/internal/MutationSpecificationImpl.java
index e646307365a6..d2d55eabaaa3 100644
--- a/hibernate-core/src/main/java/org/hibernate/query/programmatic/internal/MutationSpecificationImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/query/programmatic/internal/MutationSpecificationImpl.java
@@ -62,7 +62,7 @@ public MutationSpecificationImpl(CriteriaDelete criteriaQuery) {
 	}
 
 	@Override
-	public MutationSpecification addRestriction(Restriction restriction) {
+	public MutationSpecification restrict(Restriction restriction) {
 		specifications.add( (sqmStatement, mutationTargetRoot) -> {
 			final SqmPredicate sqmPredicate = (SqmPredicate) restriction.toPredicate(
 					mutationTargetRoot,
@@ -74,7 +74,7 @@ public MutationSpecification addRestriction(Restriction restriction) {
 	}
 
 	@Override
-	public MutationSpecification addAugmentation(Augmentation augmentation) {
+	public MutationSpecification augment(Augmentation augmentation) {
 		specifications.add( (sqmStatement, mutationTargetRoot) ->
 				augmentation.augment( sqmStatement.nodeBuilder(), sqmStatement, mutationTargetRoot ) );
 		return this;
diff --git a/hibernate-core/src/main/java/org/hibernate/query/programmatic/internal/SelectionSpecificationImpl.java b/hibernate-core/src/main/java/org/hibernate/query/programmatic/internal/SelectionSpecificationImpl.java
index 00198c9a6345..399aa0a4926f 100644
--- a/hibernate-core/src/main/java/org/hibernate/query/programmatic/internal/SelectionSpecificationImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/query/programmatic/internal/SelectionSpecificationImpl.java
@@ -64,7 +64,7 @@ public SelectionSpecificationImpl(CriteriaQuery criteriaQuery) {
 	}
 
 	@Override
-	public SelectionSpecification addRestriction(Restriction restriction) {
+	public SelectionSpecification restrict(Restriction restriction) {
 		specifications.add( (sqmStatement, root) -> {
 			final SqmPredicate sqmPredicate = SqmUtil.restriction( sqmStatement, resultType, restriction );
 			sqmStatement.getQuerySpec().applyPredicate( sqmPredicate );
@@ -73,20 +73,20 @@ public SelectionSpecification addRestriction(Restriction restriction) {
 	}
 
 	@Override
-	public SelectionSpecification addAugmentation(Augmentation augmentation) {
+	public SelectionSpecification augment(Augmentation augmentation) {
 		specifications.add( (sqmStatement, root) ->
 				augmentation.augment( sqmStatement.nodeBuilder(), sqmStatement, root ) );
 		return this;
 	}
 
 	@Override
-	public SelectionSpecification addFetching(Path fetchPath) {
+	public SelectionSpecification fetch(Path fetchPath) {
 		specifications.add( (sqmStatement, root) -> fetchPath.fetch( root ) );
 		return this;
 	}
 
 	@Override
-	public SelectionSpecification addOrdering(Order order) {
+	public SelectionSpecification sort(Order order) {
 		specifications.add( (sqmStatement, root) -> {
 			addOrder( order, sqmStatement );
 		} );
@@ -94,7 +94,7 @@ public SelectionSpecification addOrdering(Order order) {
 	}
 
 	@Override
-	public final SelectionSpecification setOrdering(Order order) {
+	public final SelectionSpecification resort(Order order) {
 		specifications.add( (sqmStatement, root) -> {
 			sqmStatement.getQuerySpec().setOrderByClause( new SqmOrderByClause() );
 			addOrder( order, sqmStatement );
@@ -103,7 +103,7 @@ public final SelectionSpecification setOrdering(Order order) {
 	}
 
 	@Override
-	public final SelectionSpecification setOrdering(List> orders) {
+	public final SelectionSpecification resort(List> orders) {
 		specifications.add( (sqmStatement, root) -> {
 			sqmStatement.getQuerySpec().setOrderByClause( new SqmOrderByClause() );
 			orders.forEach( order -> addOrder( order, sqmStatement ) );
diff --git a/hibernate-core/src/main/java/org/hibernate/query/restriction/Path.java b/hibernate-core/src/main/java/org/hibernate/query/restriction/Path.java
index 24cf1d7c5aa1..b3023947ed80 100644
--- a/hibernate-core/src/main/java/org/hibernate/query/restriction/Path.java
+++ b/hibernate-core/src/main/java/org/hibernate/query/restriction/Path.java
@@ -19,8 +19,9 @@
  * the root entity type of the query.
  * 
  * SelectionSpecification.create(Book.class)
- *         .addRestriction(from(Book.class).to(Book_.publisher).to(Publisher_.name)
+ *         .restrict(from(Book.class).to(Book_.publisher).to(Publisher_.name)
  *                         .equalTo("Manning"))
+ *         .fetch(from(Book.class).to(Book_.publisher))
  *         .createQuery(session)
  *         .getResultList()
  * 
diff --git a/hibernate-core/src/main/java/org/hibernate/query/restriction/Restriction.java b/hibernate-core/src/main/java/org/hibernate/query/restriction/Restriction.java index 8831ae7cce1b..e35f1719177c 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/restriction/Restriction.java +++ b/hibernate-core/src/main/java/org/hibernate/query/restriction/Restriction.java @@ -24,9 +24,9 @@ * {@link SelectionQuery#addRestriction(Restriction)}. *
  * SelectionSpecification.create(Book.class)
- *         .addRestriction(Restriction.like(Book_.title, "%Hibernate%", false))
- *         .addRestriction(Restriction.greaterThan(Book_.pages, 100))
- *         .setOrder(Order.desc(Book_.title))
+ *         .restrict(Restriction.like(Book_.title, "%Hibernate%", false))
+ *         .restrict(Restriction.greaterThan(Book_.pages, 100))
+ *         .sort(Order.desc(Book_.title))
  *         .createQuery(session)
  *         .getResultList();
  * 
@@ -50,7 +50,7 @@ * * @see org.hibernate.query.programmatic.SelectionSpecification * @see org.hibernate.query.programmatic.MutationSpecification - * @see org.hibernate.query.programmatic.QuerySpecification#addRestriction(Restriction) + * @see org.hibernate.query.programmatic.QuerySpecification#restrict(Restriction) * * @see Path * @see Order diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/dynamic/SimpleQuerySpecificationTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/dynamic/SimpleQuerySpecificationTests.java index 8f586b5416e4..b7995ceee8ab 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/dynamic/SimpleQuerySpecificationTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/dynamic/SimpleQuerySpecificationTests.java @@ -38,7 +38,7 @@ void testSimpleSelectionOrder(SessionFactoryScope factoryScope) { factoryScope.inTransaction( (session) -> { sqlCollector.clear(); SelectionSpecification.create( BasicEntity.class, "from BasicEntity" ) - .addOrdering( Order.asc( BasicEntity_.position ) ) + .sort( Order.asc( BasicEntity_.position ) ) .createQuery( session ) .list(); } ); @@ -54,8 +54,8 @@ void testSimpleSelectionOrderMultiple(SessionFactoryScope factoryScope) { factoryScope.inTransaction( (session) -> { sqlCollector.clear(); SelectionSpecification.create( BasicEntity.class, "from BasicEntity" ) - .addOrdering( Order.asc( BasicEntity_.position ) ) - .addOrdering( Order.asc( BasicEntity_.id ) ) + .sort( Order.asc( BasicEntity_.position ) ) + .sort( Order.asc( BasicEntity_.id ) ) .createQuery( session ) .list(); } ); @@ -71,7 +71,7 @@ void testSimpleSelectionSetOrdering(SessionFactoryScope factoryScope) { factoryScope.inTransaction( (session) -> { sqlCollector.clear(); SelectionSpecification.create( BasicEntity.class, "from BasicEntity" ) - .setOrdering( Order.asc( BasicEntity_.position ) ) + .resort( Order.asc( BasicEntity_.position ) ) .createQuery( session ) .list(); } ); @@ -87,7 +87,7 @@ void testSimpleSelectionSetOrderingMultiple(SessionFactoryScope factoryScope) { factoryScope.inTransaction( (session) -> { sqlCollector.clear(); SelectionSpecification.create( BasicEntity.class, "from BasicEntity" ) - .setOrdering( List.of( Order.asc( BasicEntity_.position ), Order.asc( BasicEntity_.id ) ) ) + .resort( List.of( Order.asc( BasicEntity_.position ), Order.asc( BasicEntity_.id ) ) ) .createQuery( session ) .list(); } ); @@ -103,8 +103,8 @@ void testSimpleSelectionSetOrderingReplace(SessionFactoryScope factoryScope) { factoryScope.inTransaction( (session) -> { sqlCollector.clear(); SelectionSpecification.create( BasicEntity.class, "from BasicEntity" ) - .setOrdering( Order.asc( BasicEntity_.id ) ) - .setOrdering( Order.asc( BasicEntity_.position ) ) + .resort( Order.asc( BasicEntity_.id ) ) + .resort( Order.asc( BasicEntity_.position ) ) .createQuery( session ) .list(); } ); @@ -115,8 +115,8 @@ void testSimpleSelectionSetOrderingReplace(SessionFactoryScope factoryScope) { factoryScope.inTransaction( (session) -> { sqlCollector.clear(); SelectionSpecification.create( BasicEntity.class, "from BasicEntity" ) - .addOrdering( Order.asc( BasicEntity_.id ) ) - .setOrdering( Order.asc( BasicEntity_.position ) ) + .sort( Order.asc( BasicEntity_.id ) ) + .resort( Order.asc( BasicEntity_.position ) ) .createQuery( session ) .list(); } ); @@ -132,7 +132,7 @@ void testSimpleSelectionRestriction(SessionFactoryScope factoryScope) { factoryScope.inTransaction( (session) -> { sqlCollector.clear(); SelectionSpecification.create( BasicEntity.class, "from BasicEntity" ) - .addRestriction( Restriction.restrict( BasicEntity_.position, Range.closed( 1, 5 ) ) ) + .restrict( Restriction.restrict( BasicEntity_.position, Range.closed( 1, 5 ) ) ) .createQuery( session ) .list(); } ); @@ -148,7 +148,7 @@ void testSimpleMutationRestriction(SessionFactoryScope factoryScope) { factoryScope.inTransaction( (session) -> { sqlCollector.clear(); MutationSpecification.create( BasicEntity.class, "delete BasicEntity" ) - .addRestriction( Restriction.restrict( BasicEntity_.position, Range.closed( 1, 5 ) ) ) + .restrict( Restriction.restrict( BasicEntity_.position, Range.closed( 1, 5 ) ) ) .createQuery( session ) .executeUpdate(); } ); @@ -164,7 +164,7 @@ void testRootEntityForm(SessionFactoryScope factoryScope) { factoryScope.inTransaction( (session) -> { sqlCollector.clear(); SelectionSpecification.create( BasicEntity.class ) - .addOrdering( Order.asc( BasicEntity_.position ) ) + .sort( Order.asc( BasicEntity_.position ) ) .createQuery( session ) .getResultList(); } ); @@ -185,8 +185,8 @@ void testCriteriaForm(SessionFactoryScope factoryScope) { query.select( entity ); query.where( criteriaBuilder.like( entity.get( BasicEntity_.name ), "%" ) ); SelectionSpecification.create( query ) - .addOrdering( Order.asc( BasicEntity_.position ) ) - .addFetching( Path.from(BasicEntity.class).to( BasicEntity_.other ) ) + .sort( Order.asc( BasicEntity_.position ) ) + .fetch( Path.from(BasicEntity.class).to( BasicEntity_.other ) ) .createQuery( session ) .getResultList(); } ); @@ -202,8 +202,8 @@ void testAugmentation(SessionFactoryScope factoryScope) { factoryScope.inTransaction( (session) -> { sqlCollector.clear(); SelectionSpecification.create( BasicEntity.class ) - .addAugmentation( (builder, query, entity) -> query.where( builder.like( entity.get( BasicEntity_.name ), "%" ) ) ) - .addOrdering( Order.asc( BasicEntity_.position ) ) + .augment( (builder, query, entity) -> query.where( builder.like( entity.get( BasicEntity_.name ), "%" ) ) ) + .sort( Order.asc( BasicEntity_.position ) ) .createQuery( session ) .getResultList(); } ); @@ -219,13 +219,13 @@ void testAugmentationViaCriteriaDefinition(SessionFactoryScope factoryScope) { factoryScope.inTransaction( (session) -> { sqlCollector.clear(); SelectionSpecification.create( BasicEntity.class ) - .addAugmentation( (builder, query, entity) -> + .augment( (builder, query, entity) -> new CriteriaDefinition<>( query ) {{ where( like( entity.get( BasicEntity_.name ), "%" ), equal( entity.get( BasicEntity_.position), 1 ) ); }} ) - .addOrdering( Order.asc( BasicEntity_.position ) ) + .sort( Order.asc( BasicEntity_.position ) ) .createQuery( session ) .getResultList(); } ); @@ -240,7 +240,7 @@ void testBaseParameters(SessionFactoryScope factoryScope) { factoryScope.inTransaction( (session) -> { sqlCollector.clear(); SelectionSpecification.create( BasicEntity.class, "from BasicEntity where id > :id" ) - .addRestriction( Restriction.restrict( BasicEntity_.position, Range.closed( 1, 5 ) ) ) + .restrict( Restriction.restrict( BasicEntity_.position, Range.closed( 1, 5 ) ) ) .createQuery( session ) .setParameter( "id", 200 ) .getResultList();