You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "borinquenkid (via GitHub)" <gi...@apache.org> on 2026/10/22 17:40:36 UTC

[PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

borinquenkid opened a new pull request, #16733:
URL: https://github.com/apache/grails-core/pull/16733

   ## Summary
   
   Resolves #16563 on 8.x. A plugin or an application can extend the Hibernate 7 criteria builder with its own criteria and orders:
   
   - A criterion handler can take the query's `QueryPathContext` (a new small interface that `JpaQueryContext` implements: `getRoot()`, `getFullyQualifiedPath(String)`, `getFullyQualifiedExpression(String)`). Through it a handler resolves `alias.property` or `association.property` to the join GORM created for the association, so a custom criterion and a built-in one on the same association restrict the same row instead of each joining the association again. A four-argument handler keeps working; `ContextualCriterionHandler` is the five-argument form, and a closure with five parameters is coerced to it.
   - An `OrderHandler` turns a `Query.Order` subclass into a JPA order by any expression, in its place among the query's orders, registered in code or through a `META-INF/services` `OrderHandlerProvider`.
   - Handler discovery waits for the providers: `loadServiceProviders` loads under a lock and publishes its flag only after both `ServiceLoader` loops, so a query that arrives during the discovery no longer decides, with the handlers still unregistered, that an order has no handler. A handler registered in code stays ahead of a discovered one.
   - A count query leaves its orders out, handled ones too (the fix of #16731, included here as the same commit so this branch tests against it; the merge-up reconciles them).
   
   This is the 8.1.x version of #16696, which was reviewed on the Java-to-Groovy Hibernate 7 branch and answers that review: the interface instead of the context class, the discovery race, the count query, the reversed-order and `DetachedCriteria.list()` coverage, and the restored workflow triggers. #16696 becomes the merge-up of this pull request onto that branch.
   
   Documented in the GORM for Hibernate 7 guide (Extending the Criteria Builder) and the what's new of Grails 8; the `criteria-extension` example application exercises both handler kinds through providers.
   
   ## Verification
   
   - `HibernateCriteriaBuilderDirectSpec`: a contextual handler on an association path, before and after the association block; an order handler through the builder and through `DetachedCriteria.list()`; a `count()` with a handled order; a handler returning `null`.
   - `OrderHandlerDiscoverySpec`: one thread blocked inside a provider found through `META-INF/services`, a second lookup waits and receives the handler; fails with the previous flag.
   - `PredicateGeneratorSpec`, `JpaCriteriaQueryCreatorSpec`: the translator-level cases.
   - `:grails-data-hibernate7-core:test`, `checkstyleMain`, `codenarcTest`: see the CI run.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on code in PR #16733:
URL: https://github.com/apache/grails-core/pull/16733#discussion_r4352272438


##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PredicateGenerator.java:
##########
@@ -119,13 +235,68 @@ public interface CriterionHandlerProvider {
     public static final Map<Class<? extends Query.Criterion>, CriterionHandler> CUSTOM_HANDLERS =
         new ConcurrentHashMap<>();
 
-    private static final AtomicBoolean SERVICE_LOADERS_INITIALIZED = new AtomicBoolean(false);
+    public static final Map<Class<? extends Query.Order>, OrderHandler> CUSTOM_ORDER_HANDLERS =

Review Comment:
   Does this map need to be public? `registerOrderHandler`, `orderHandler` and `clearCustomOrderHandlers` already cover registration, lookup and cleanup. Code that reads the map directly skips `loadServiceProviders()`, so it can find no handler before discovery has run, which is the situation the new lock prevents. This is new API in 8.1, so making the map private keeps it out of the public contract. `CUSTOM_HANDLERS` is already public, so I'd leave that one alone.



##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PredicateGenerator.java:
##########
@@ -90,6 +90,122 @@ Predicate handle(
             HibernateCriteriaBuilder criteriaBuilder,
             Query.Criterion criterion
         );
+
+        /**
+         * Converts a criterion with the context of the query it belongs to. The context resolves a property path
+         * the way the built-in criteria do: {@link QueryPathContext#getFullyQualifiedPath(String)} turns
+         * {@code alias.property}, for an alias created with {@code createAlias}, or {@code association.property}
+         * into a path on the join GORM created for that association, so a custom criterion and a GORM criterion on
+         * the same association restrict the same row instead of each joining the association again. This default
+         * ignores the context and calls {@link #handle(AbstractQuery, From, HibernateCriteriaBuilder, Query.Criterion)};
+         * a handler that needs the context implements {@link ContextualCriterionHandler}.
+         *
+         * @param criteriaQuery the query or subquery the predicate is for
+         * @param root the root of that query
+         * @param criteriaBuilder the criteria builder
+         * @param criterion the criterion to convert
+         * @param context the context of the query: its root, its joins and its aliases
+         * @return the predicate, or {@code null} to add none
+         * @since 8.1
+         */
+        default Predicate handle(
+            AbstractQuery<?> criteriaQuery,
+            From<?, ?> root,
+            HibernateCriteriaBuilder criteriaBuilder,
+            Query.Criterion criterion,
+            QueryPathContext context
+        ) {
+            return handle(criteriaQuery, root, criteriaBuilder, criterion);
+        }
+    }
+
+    /**
+     * A {@link CriterionHandler} that is given the context of the query, through which it resolves property paths
+     * with {@link QueryPathContext#getFullyQualifiedPath(String)}. A closure with five parameters is coerced to it:

Review Comment:
   A five-parameter closure only becomes a `ContextualCriterionHandler` with the explicit `as`. Without it, Groovy coerces the closure to `CriterionHandler`, and the query then fails at run time:
   
   ```groovy
   PredicateGenerator.registerCriterionHandler(CriteriaTestPathLike) { query, root, cb, criterion, context ->
       cb.like(context.getFullyQualifiedPath(criterion.property) as Expression<String>, criterion.value as String)
   }
   new DetachedCriteria(CriteriaTestEntity).build { add(new CriteriaTestPathLike('name', 'A%')) }.list()
   ```
   ```
   groovy.lang.MissingMethodException: No signature of method: doCall ... is applicable for argument types:
   (SqmSelectStatement, SqmRoot, SqmCriteriaNodeBuilder...)
   ```
   
   This is easy to hit because `registerOrderHandler` takes the same closure shape without the `as`, and the guide shows it that way. The two registrations look alike, but only the order one works.
   
   Could `registerCriterionHandler` get a `Closure` overload that wraps the closure as a `ContextualCriterionHandler` when `getMaximumNumberOfParameters()` is 5, and as a `CriterionHandler` otherwise? I checked on Groovy 5.1.2: Groovy chooses a `Closure` parameter over SAM coercion, both dynamically and under `@CompileStatic`, and an explicit `as ContextualCriterionHandler` still picks the existing overload. With that overload both shapes work without the `as`. If you'd rather keep the API as it is, please say in this javadoc and in the guide that the `as` is required and what happens without it.



##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/QueryPathContext.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2024-2025 the original author or authors.

Review Comment:
   This is a new file, so it should have the ASF source header, as `OrderHandlerDiscoverySpec` and the new example classes in this PR do, not the "original author or authors" header. RAT accepts both (the existing files in this package that use the old header pass it), so CI won't flag it.



##########
grails-data-hibernate7/core/src/test/groovy/grails/orm/HibernateCriteriaBuilderDirectSpec.groovy:
##########
@@ -389,6 +390,129 @@ class HibernateCriteriaBuilderDirectSpec extends HibernateGormDatastoreSpec {
         cleanup:
         PredicateGenerator.clearCustomCriterionHandlers()
     }
+
+    void "a count query leaves the criteria's orders out"() {
+        expect: "a count with an order counts every row instead of failing on the order by"
+        new DetachedCriteria(CriteriaTestEntity).build { order('amount', 'desc') }.count() == 4L
+        new DetachedCriteria(CriteriaTestEntity).build {
+            gt('amount', 15)
+            order('name')
+        }.count() == 3L
+
+        and: "a row count projection with an order returns the count"
+        c.list {
+            projections { rowCount() }
+            order('amount')
+        } == [4L]
+
+        and: "the builder's count with an order counts every row"
+        new HibernateCriteriaBuilder(CriteriaTestEntity, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+                .count { order('amount', 'desc') } == 4L
+
+        and: "the order still applies to the list"
+        new DetachedCriteria(CriteriaTestEntity).build { order('amount', 'desc') }.list()*.name == ['D', 'C', 'B', 'A']
+    }
+
+    void "a contextual criterion handler resolves an association path to the join GORM created for it"() {
+        given: "a parent with two children, and a handler that resolves its criterion's path through the context"
+        var parent = CriteriaTestEntity.findByName('A')
+        parent.addToChildren(new CriteriaTestChild(name: 'Kid'))
+        parent.addToChildren(new CriteriaTestChild(name: 'Other')).save(flush: true)
+        PredicateGenerator.registerCriterionHandler(CriteriaTestPathLike, { query, root, cb, criterion, context ->
+            def c = criterion as CriteriaTestPathLike
+            cb.like(context.getFullyQualifiedPath(c.property) as Expression<String>, c.value as String)
+        } as PredicateGenerator.ContextualCriterionHandler)
+
+        when: "a GORM criterion and the custom criterion restrict the same association"
+        List<CriteriaTestEntity> both = new DetachedCriteria(CriteriaTestEntity).build {
+            children { eq('name', 'Kid') }
+            add(new CriteriaTestPathLike('children.name', 'K%'))
+        }.list()
+        List<CriteriaTestEntity> different = new DetachedCriteria(CriteriaTestEntity).build {
+            children { eq('name', 'Kid') }
+            add(new CriteriaTestPathLike('children.name', 'O%'))
+        }.list()
+
+        then: "a child matching both criteria is found"
+        both*.name == ['A']
+
+        and: "two children matching one criterion each are not: the handler used the join GORM created, not a second one"
+        different.empty
+
+        when: "the custom criterion comes before the association block"

Review Comment:
   The first case in #16563 is an alias from `createAlias`, and the guide and the `QueryPathContext` javadoc mention it first, but this feature only tests association paths. A `createAlias` alias reaches the registry differently: a `HibernateAlias` is registered up front, while the association block's alias comes from alias discovery. I probed it, and the alias shares the join both in a detached criteria and in the builder (through `hibernateQuery.add(...)`):
   
   ```groovy
   createAlias('children', 'ch')
   eq('ch.name', 'Kid')
   add(new CriteriaTestPathLike('ch.name', 'O%'))   // [] ; with 'K%': ['A']
   ```
   
   Could you add that case here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

Posted by "borinquenkid (via GitHub)" <gi...@apache.org>.
borinquenkid commented on code in PR #16733:
URL: https://github.com/apache/grails-core/pull/16733#discussion_r4361020581


##########
grails-test-examples/hibernate7/criteria-extension/src/main/resources/META-INF/services/org.grails.orm.hibernate.query.PredicateGenerator$OrderHandlerProvider:
##########
@@ -0,0 +1 @@
+example.query.PriceDistanceOrderHandlerProvider

Review Comment:
   Done in 54a44543b2: the example's order provider file has the ASF header, as the test resource's has.
   



##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/QueryPathContext.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2024-2025 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.orm.hibernate.query;
+
+import jakarta.persistence.criteria.Expression;
+import jakarta.persistence.criteria.From;
+import jakarta.persistence.criteria.Path;
+
+/**
+ * What a criterion or order handler sees of the query it converts for: the root of the query and the resolution
+ * of property paths the way the built-in criteria resolve them. {@code alias.property}, for an alias created with
+ * {@code createAlias}, or {@code association.property} becomes a path on the join GORM created for that
+ * association, so a custom criterion and a built-in one on the same association restrict the same row rather
+ * than each joining the association again.
+ *
+ * @since 8.1
+ */
+public interface QueryPathContext {
+
+    /**
+     * @return the root of the query or subquery the handler converts for
+     */
+    From<?, ?> getRoot();
+
+    /**
+     * @param path a property path: {@code property}, {@code association.property} or {@code alias.property}
+     * @return the path, or {@code null} when the property path resolves to an expression that is not a path
+     */
+    Path<?> getFullyQualifiedPath(String path);
+
+    /**
+     * @param path a property path, or the alias of a projection

Review Comment:
   Done in 54a44543b2, with one limit. `getFullyQualifiedExpression('total')` now returns the projection a `sqlProjection` alias stands for when no property resolves the path, and a handler that orders through it gets `order by 1 desc`, asserted next to the `getSelectionAlias` case. When a property has the alias's name the property wins, because `a restriction on a property is not resolved to a SQL projection with the same alias` is an existing behavior with its own specs; `getSelectionAlias` asks for the alias alone in that case. The javadoc says so.
   



##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JpaQueryContext.java:
##########
@@ -173,6 +175,7 @@ public Expression<?> getAliasedExpression(String alias) {
         return expr;
     }
 
+    @Override
     public Expression<?> getFullyQualifiedExpression(String path) {

Review Comment:
   Same change as the thread above (54a44543b2): the path resolves to the recorded selection when no property has the name, and the order goes through `getFullyQualifiedExpression('total')` in a spec of its own.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

Posted by "borinquenkid (via GitHub)" <gi...@apache.org>.
borinquenkid merged PR #16733:
URL: https://github.com/apache/grails-core/pull/16733


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on code in PR #16733:
URL: https://github.com/apache/grails-core/pull/16733#discussion_r4360834011


##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JpaQueryContext.java:
##########
@@ -173,6 +175,7 @@ public Expression<?> getAliasedExpression(String alias) {
         return expr;
     }
 
+    @Override
     public Expression<?> getFullyQualifiedExpression(String path) {

Review Comment:
   I probed this at 1e47f7ed5d to see what each lookup returns for a `sqlProjection` alias, with `width * 10 as scaled` where no `scaled` property exists and `width * 10 as height` where `height` is a property:
   
   | alias | `getFullyQualifiedExpression` | `getSelectionAlias` | built-in `order(alias)` | built-in `eq(alias, …)` |
   |---|---|---|---|---|
   | `scaled` | `null`; `cb.desc(null)` then fails with "Ambiguous method overloading for SqmCriteriaNodeBuilder#desc" | the projection | `order by 1 desc` | "Cannot use comparison criteria on non-existent property [scaled]" |
   | `height` | the property, `order by spb1_0.height desc` | the projection | `order by 1 desc` | `where spb1_0.height=?` |
   
   For `sqlGroupProjection 'width, sum(height) as total'`, a handler using `getSelectionAlias('total')` gives `order by 2 desc`, the same SQL as `order('total', 'desc')`.
   
   The two built-in columns of that table are not an accident of the translator. They are the rule SQL, Hibernate 5 and this module already follow:
   
   - SQL scopes a select alias to ORDER BY, where it wins over a column of the same name, and never to WHERE. On H2 2.5.250, the test database: `select width * 10 as height from t order by height desc` returns 40, 20; `... where height = 9` restricts the column; `... where scaled = 20` fails with `Column "SCALED" not found`.
   - Hibernate 5's Criteria API, which the plugin in #16563 is porting from, does the same. `Order.toSqlString` resolves through `CriteriaQueryTranslator.getColumnsUsingProjection`, which first looks for a projection alias and then for a property; `SimpleExpression.toSqlString`, behind `eq` and the other restrictions, resolves through `findColumns`, which looks for a property only (hibernate-core 5.6.11).
   - This module encoded it when `sqlProjection` landed: `assignOrderBy` checks the `sqlProjection` alias before the property, and `registerSelectionAlias` keeps the alias out of property resolution, with "Column aliases never shadow properties in restrictions" in cb1f659bd0 (#16548).
   
   Folding the selection into `getFullyQualifiedExpression` changes that behavior, because the built-in predicates resolve through the same method and `assignCriteria` runs after the projections are registered. Selection first makes `eq('height', 9)` restrict the projection instead of the column on every query whose projection alias matches a property, which is the shadowing the commit above rules out and SQL does not do. Selection as a fallback keeps `eq` as it is, but then a custom order resolves `height` to the property where `order('height')` resolves it to the projection, so the built-in order and the handler order the same alias differently.
   
   Two lookups avoid both. An order handler that checks `getSelectionAlias` first and `getFullyQualifiedExpression` second orders exactly as `order(alias)` and as Hibernate 5's `Order` do, and a criterion handler that uses `getFullyQualifiedExpression` alone restricts exactly as `eq` does. So I would keep the accessor this commit adds rather than change the resolver.
   
   What is wrong at this commit is the contract. The `QueryPathContext.getFullyQualifiedExpression` javadoc says it takes "the alias of a projection" and returns "the expression an alias or projection stands for". That holds for an alias the translator registers with `registerAlias` and not for the column alias of a `sqlProjection`, which is where this thread started. Could the javadoc say which aliases it resolves and point to `getSelectionAlias` for the column alias of a `sqlProjection` or `sqlGroupProjection`, and could the guide's order-handler paragraph say to check `getSelectionAlias` first, the way `order(alias)` does?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #16733:
URL: https://github.com/apache/grails-core/pull/16733#discussion_r4352310075


##########
grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/hibernatequery/OrderHandlerDiscoverySpec.groovy:
##########
@@ -0,0 +1,115 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package grails.gorm.tests.hibernatequery
+
+import java.util.concurrent.Callable
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.ExecutorService
+import java.util.concurrent.Executors
+import java.util.concurrent.Future
+import java.util.concurrent.TimeUnit
+import java.util.concurrent.TimeoutException
+
+import spock.lang.Specification
+
+import org.grails.datastore.mapping.query.Query
+import org.grails.orm.hibernate.query.PredicateGenerator
+
+/**
+ * The handler providers are discovered on first use. A query that arrives while another thread discovers them must
+ * wait for the discovery instead of deciding, with the handlers still unregistered, that an order has no handler.
+ * {@link OrderHandlerDiscoveryProvider} is on the test classpath through {@code META-INF/services} and blocks inside
+ * its discovery while the spec holds its gate.
+ */
+class OrderHandlerDiscoverySpec extends Specification {
+
+    void cleanup() {
+        OrderHandlerDiscoveryProvider.gate.countDown()
+        OrderHandlerDiscoveryProvider.gate = new CountDownLatch(0)
+        PredicateGenerator.clearCustomOrderHandlers()
+    }
+
+    void "a query that arrives while the providers load waits for them and gets the discovered order handler"() {
+        given: "discovery has not run, and the provider blocks until the spec releases it"
+        PredicateGenerator.clearCustomOrderHandlers()
+        OrderHandlerDiscoveryProvider.gate = new CountDownLatch(1)
+        OrderHandlerDiscoveryProvider.entered = new CountDownLatch(1)
+        ExecutorService executor = Executors.newFixedThreadPool(2)
+        Callable<PredicateGenerator.OrderHandler> lookup = { PredicateGenerator.orderHandler(OrderHandlerDiscoveryOrder) }
+
+        when: "one thread starts the discovery and blocks inside the provider, and a second asks for the handler meanwhile"
+        Future<PredicateGenerator.OrderHandler> first = executor.submit(lookup)
+        boolean providerEntered = OrderHandlerDiscoveryProvider.entered.await(10, TimeUnit.SECONDS)
+        Future<PredicateGenerator.OrderHandler> second = executor.submit(lookup)
+        boolean secondAnsweredDuringDiscovery = true
+        try {
+            second.get(500, TimeUnit.MILLISECONDS)
+        } catch (TimeoutException ignored) {
+            secondAnsweredDuringDiscovery = false
+        }
+        OrderHandlerDiscoveryProvider.gate.countDown()
+
+        then: "the second caller waited for the discovery, and both callers get the discovered handler"
+        providerEntered
+        !secondAnsweredDuringDiscovery
+        first.get(10, TimeUnit.SECONDS) != null
+        second.get(10, TimeUnit.SECONDS) != null
+
+        cleanup:
+        executor.shutdownNow()
+    }
+
+    void "a handler registered in code is kept over the discovered one"() {
+        given:
+        PredicateGenerator.clearCustomOrderHandlers()
+        PredicateGenerator.OrderHandler registered = { query, root, cb, order, context -> null }
+        PredicateGenerator.registerOrderHandler(OrderHandlerDiscoveryOrder, registered)
+
+        expect:
+        PredicateGenerator.orderHandler(OrderHandlerDiscoveryOrder).is(registered)
+    }
+
+}
+
+class OrderHandlerDiscoveryOrder extends Query.Order {
+
+    OrderHandlerDiscoveryOrder() {
+        super('discovered')
+    }
+
+}
+
+class OrderHandlerDiscoveryProvider implements PredicateGenerator.OrderHandlerProvider {
+
+    static volatile CountDownLatch gate = new CountDownLatch(0)
+    static volatile CountDownLatch entered = new CountDownLatch(0)
+
+    @Override
+    Class<? extends Query.Order> orderType() {
+        OrderHandlerDiscoveryOrder
+    }
+
+    @Override
+    PredicateGenerator.OrderHandler orderHandler() {
+        entered.countDown()
+        gate.await()

Review Comment:
   `CountDownLatch#await()` can throw `InterruptedException`. In this test provider, an interrupt (e.g., from `shutdownNow()` or a failing test) would bubble out of ServiceLoader discovery and can create hard-to-debug, intermittent failures. Consider catching `InterruptedException`, restoring the interrupt flag (`Thread.currentThread().interrupt()`), and failing fast with a clear runtime exception (or unblocking in a deterministic way) so test behavior remains predictable.



##########
grails-test-examples/hibernate7/criteria-extension/src/main/resources/META-INF/services/org.grails.orm.hibernate.query.PredicateGenerator$OrderHandlerProvider:
##########
@@ -0,0 +1 @@
+example.query.PriceDistanceOrderHandlerProvider

Review Comment:
   This newly added ServiceLoader provider file lacks the Apache license header comment that is present in the similar test resource provider file. For consistency (and to avoid potential license-compliance tooling issues), consider adding the standard header using `#` comment lines above the provider class name.



##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PredicateGenerator.java:
##########
@@ -119,13 +235,68 @@ public interface CriterionHandlerProvider {
     public static final Map<Class<? extends Query.Criterion>, CriterionHandler> CUSTOM_HANDLERS =
         new ConcurrentHashMap<>();
 
-    private static final AtomicBoolean SERVICE_LOADERS_INITIALIZED = new AtomicBoolean(false);
+    public static final Map<Class<? extends Query.Order>, OrderHandler> CUSTOM_ORDER_HANDLERS =
+        new ConcurrentHashMap<>();
+
+    private static final Object SERVICE_LOADER_LOCK = new Object();
 
+    private static volatile boolean serviceLoadersInitialized = false;
+
+    /**
+     * Loads the handler providers once. A caller that arrives while another thread is loading them waits until the
+     * loading is complete, so no query decides on a handler before the discovered ones are registered. A discovered
+     * handler never replaces one registered in code: the maps keep the first registration.

Review Comment:
   The sentence β€œthe maps keep the first registration” is misleading now that `registerOrderHandler(...)` (and the existing criterion registration) uses `put(...)`, which intentionally allows code-registered handlers to override ServiceLoader-discovered handlers. Suggest rewording to accurately reflect the rule: discovery uses `putIfAbsent` so it does not override existing registrations, while explicit registration in code takes precedence.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16733:
URL: https://github.com/apache/grails-core/pull/16733#issuecomment-6376957241

   ## πŸ”Ž No tests executed πŸ”Ž
   
   🏷️ Commit: a46a5c9533a3a5bd57bb1afde52e1211b957b140
   ▢️ Tests:  0 executed
   βšͺ️ Checks: 26/26 completed
   
   ---
   _Learn more about TestLens at [testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

Posted by "jamesfredley (via GitHub)" <gi...@apache.org>.
jamesfredley commented on code in PR #16733:
URL: https://github.com/apache/grails-core/pull/16733#discussion_r4352460189


##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/QueryPathContext.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2024-2025 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.orm.hibernate.query;
+
+import jakarta.persistence.criteria.Expression;
+import jakarta.persistence.criteria.From;
+import jakarta.persistence.criteria.Path;
+
+/**
+ * What a criterion or order handler sees of the query it converts for: the root of the query and the resolution
+ * of property paths the way the built-in criteria resolve them. {@code alias.property}, for an alias created with
+ * {@code createAlias}, or {@code association.property} becomes a path on the join GORM created for that
+ * association, so a custom criterion and a built-in one on the same association restrict the same row rather
+ * than each joining the association again.
+ *
+ * @since 8.1
+ */
+public interface QueryPathContext {
+
+    /**
+     * @return the root of the query or subquery the handler converts for
+     */
+    From<?, ?> getRoot();
+
+    /**
+     * @param path a property path: {@code property}, {@code association.property} or {@code alias.property}
+     * @return the path, or {@code null} when the property path resolves to an expression that is not a path
+     */
+    Path<?> getFullyQualifiedPath(String path);
+
+    /**
+     * @param path a property path, or the alias of a projection

Review Comment:
   `context.getFullyQualifiedExpression('total')` does not return the `sqlProjection` aliased `total`. The translator stores that alias in `selectionAliases`, and this lookup only asks the expression resolver. The result is null, or an entity property named `total`.
   
   Expose a selection-alias lookup. Leave predicate resolution alone. Please order by that alias and assert the projected expression is used.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16733:
URL: https://github.com/apache/grails-core/pull/16733#issuecomment-6392195491

   ## πŸ”Ž No tests executed πŸ”Ž
   
   🏷️ Commit: 591bde1fe318ecb83d8c77eb9889265411ae8d97
   ▢️ Tests:  0 executed
   βšͺ️ Checks: 49/49 completed
   
   ---
   _Learn more about TestLens at [testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

Posted by "borinquenkid (via GitHub)" <gi...@apache.org>.
borinquenkid commented on code in PR #16733:
URL: https://github.com/apache/grails-core/pull/16733#discussion_r4361018266


##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PredicateGenerator.java:
##########
@@ -90,6 +90,122 @@ Predicate handle(
             HibernateCriteriaBuilder criteriaBuilder,
             Query.Criterion criterion
         );
+
+        /**
+         * Converts a criterion with the context of the query it belongs to. The context resolves a property path
+         * the way the built-in criteria do: {@link QueryPathContext#getFullyQualifiedPath(String)} turns
+         * {@code alias.property}, for an alias created with {@code createAlias}, or {@code association.property}
+         * into a path on the join GORM created for that association, so a custom criterion and a GORM criterion on
+         * the same association restrict the same row instead of each joining the association again. This default
+         * ignores the context and calls {@link #handle(AbstractQuery, From, HibernateCriteriaBuilder, Query.Criterion)};
+         * a handler that needs the context implements {@link ContextualCriterionHandler}.
+         *
+         * @param criteriaQuery the query or subquery the predicate is for
+         * @param root the root of that query
+         * @param criteriaBuilder the criteria builder
+         * @param criterion the criterion to convert
+         * @param context the context of the query: its root, its joins and its aliases
+         * @return the predicate, or {@code null} to add none
+         * @since 8.1
+         */
+        default Predicate handle(
+            AbstractQuery<?> criteriaQuery,
+            From<?, ?> root,
+            HibernateCriteriaBuilder criteriaBuilder,
+            Query.Criterion criterion,
+            QueryPathContext context
+        ) {
+            return handle(criteriaQuery, root, criteriaBuilder, criterion);
+        }
+    }
+
+    /**
+     * A {@link CriterionHandler} that is given the context of the query, through which it resolves property paths
+     * with {@link QueryPathContext#getFullyQualifiedPath(String)}. A closure with five parameters is coerced to it:

Review Comment:
   Done in 54a44543b2: `registerCriterionHandler(Class, Closure)` registers a closure with five parameters as a `ContextualCriterionHandler` and any other closure as a `CriterionHandler`, so both shapes work without `as`, the way the order handler does. An explicit `as ContextualCriterionHandler` still picks the existing overload. The javadoc and the guide drop the `as`; the Direct spec registers a four and a five parameter closure without it.
   



##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PredicateGenerator.java:
##########
@@ -119,13 +235,68 @@ public interface CriterionHandlerProvider {
     public static final Map<Class<? extends Query.Criterion>, CriterionHandler> CUSTOM_HANDLERS =
         new ConcurrentHashMap<>();
 
-    private static final AtomicBoolean SERVICE_LOADERS_INITIALIZED = new AtomicBoolean(false);
+    public static final Map<Class<? extends Query.Order>, OrderHandler> CUSTOM_ORDER_HANDLERS =

Review Comment:
   Done in 54a44543b2: `CUSTOM_ORDER_HANDLERS` is private. Nothing outside `PredicateGenerator` read it; `registerOrderHandler`, `orderHandler` and `clearCustomOrderHandlers` cover registration, lookup and cleanup.
   



##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/QueryPathContext.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2024-2025 the original author or authors.

Review Comment:
   Done in 54a44543b2: `QueryPathContext` has the ASF header.
   



##########
grails-data-hibernate7/core/src/test/groovy/grails/orm/HibernateCriteriaBuilderDirectSpec.groovy:
##########
@@ -389,6 +390,129 @@ class HibernateCriteriaBuilderDirectSpec extends HibernateGormDatastoreSpec {
         cleanup:
         PredicateGenerator.clearCustomCriterionHandlers()
     }
+
+    void "a count query leaves the criteria's orders out"() {
+        expect: "a count with an order counts every row instead of failing on the order by"
+        new DetachedCriteria(CriteriaTestEntity).build { order('amount', 'desc') }.count() == 4L
+        new DetachedCriteria(CriteriaTestEntity).build {
+            gt('amount', 15)
+            order('name')
+        }.count() == 3L
+
+        and: "a row count projection with an order returns the count"
+        c.list {
+            projections { rowCount() }
+            order('amount')
+        } == [4L]
+
+        and: "the builder's count with an order counts every row"
+        new HibernateCriteriaBuilder(CriteriaTestEntity, manager.hibernateDatastore.sessionFactory, manager.hibernateDatastore)
+                .count { order('amount', 'desc') } == 4L
+
+        and: "the order still applies to the list"
+        new DetachedCriteria(CriteriaTestEntity).build { order('amount', 'desc') }.list()*.name == ['D', 'C', 'B', 'A']
+    }
+
+    void "a contextual criterion handler resolves an association path to the join GORM created for it"() {
+        given: "a parent with two children, and a handler that resolves its criterion's path through the context"
+        var parent = CriteriaTestEntity.findByName('A')
+        parent.addToChildren(new CriteriaTestChild(name: 'Kid'))
+        parent.addToChildren(new CriteriaTestChild(name: 'Other')).save(flush: true)
+        PredicateGenerator.registerCriterionHandler(CriteriaTestPathLike, { query, root, cb, criterion, context ->
+            def c = criterion as CriteriaTestPathLike
+            cb.like(context.getFullyQualifiedPath(c.property) as Expression<String>, c.value as String)
+        } as PredicateGenerator.ContextualCriterionHandler)
+
+        when: "a GORM criterion and the custom criterion restrict the same association"
+        List<CriteriaTestEntity> both = new DetachedCriteria(CriteriaTestEntity).build {
+            children { eq('name', 'Kid') }
+            add(new CriteriaTestPathLike('children.name', 'K%'))
+        }.list()
+        List<CriteriaTestEntity> different = new DetachedCriteria(CriteriaTestEntity).build {
+            children { eq('name', 'Kid') }
+            add(new CriteriaTestPathLike('children.name', 'O%'))
+        }.list()
+
+        then: "a child matching both criteria is found"
+        both*.name == ['A']
+
+        and: "two children matching one criterion each are not: the handler used the join GORM created, not a second one"
+        different.empty
+
+        when: "the custom criterion comes before the association block"

Review Comment:
   Added in 54a44543b2, as "a contextual criterion handler resolves the alias of createAlias to the join GORM created for it": the `createAlias('children', 'ch')` alias shares the join with `eq('ch.name', 'Kid')`, in a detached criteria and in the builder (through `hibernateQuery.add(...)`); `K%` finds the parent and `O%` finds none.
   



##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PredicateGenerator.java:
##########
@@ -119,13 +235,68 @@ public interface CriterionHandlerProvider {
     public static final Map<Class<? extends Query.Criterion>, CriterionHandler> CUSTOM_HANDLERS =
         new ConcurrentHashMap<>();
 
-    private static final AtomicBoolean SERVICE_LOADERS_INITIALIZED = new AtomicBoolean(false);
+    public static final Map<Class<? extends Query.Order>, OrderHandler> CUSTOM_ORDER_HANDLERS =
+        new ConcurrentHashMap<>();
+
+    private static final Object SERVICE_LOADER_LOCK = new Object();
 
+    private static volatile boolean serviceLoadersInitialized = false;
+
+    /**
+     * Loads the handler providers once. A caller that arrives while another thread is loading them waits until the
+     * loading is complete, so no query decides on a handler before the discovered ones are registered. A discovered
+     * handler never replaces one registered in code: the maps keep the first registration.

Review Comment:
   Reworded in 54a44543b2: discovery uses `putIfAbsent`, so a discovered handler does not replace one that is already registered, and registering in code uses `put`, so it replaces a discovered one.
   



##########
grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/hibernatequery/OrderHandlerDiscoverySpec.groovy:
##########
@@ -0,0 +1,115 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package grails.gorm.tests.hibernatequery
+
+import java.util.concurrent.Callable
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.ExecutorService
+import java.util.concurrent.Executors
+import java.util.concurrent.Future
+import java.util.concurrent.TimeUnit
+import java.util.concurrent.TimeoutException
+
+import spock.lang.Specification
+
+import org.grails.datastore.mapping.query.Query
+import org.grails.orm.hibernate.query.PredicateGenerator
+
+/**
+ * The handler providers are discovered on first use. A query that arrives while another thread discovers them must
+ * wait for the discovery instead of deciding, with the handlers still unregistered, that an order has no handler.
+ * {@link OrderHandlerDiscoveryProvider} is on the test classpath through {@code META-INF/services} and blocks inside
+ * its discovery while the spec holds its gate.
+ */
+class OrderHandlerDiscoverySpec extends Specification {
+
+    void cleanup() {
+        OrderHandlerDiscoveryProvider.gate.countDown()
+        OrderHandlerDiscoveryProvider.gate = new CountDownLatch(0)
+        PredicateGenerator.clearCustomOrderHandlers()
+    }
+
+    void "a query that arrives while the providers load waits for them and gets the discovered order handler"() {
+        given: "discovery has not run, and the provider blocks until the spec releases it"
+        PredicateGenerator.clearCustomOrderHandlers()
+        OrderHandlerDiscoveryProvider.gate = new CountDownLatch(1)
+        OrderHandlerDiscoveryProvider.entered = new CountDownLatch(1)
+        ExecutorService executor = Executors.newFixedThreadPool(2)
+        Callable<PredicateGenerator.OrderHandler> lookup = { PredicateGenerator.orderHandler(OrderHandlerDiscoveryOrder) }
+
+        when: "one thread starts the discovery and blocks inside the provider, and a second asks for the handler meanwhile"
+        Future<PredicateGenerator.OrderHandler> first = executor.submit(lookup)
+        boolean providerEntered = OrderHandlerDiscoveryProvider.entered.await(10, TimeUnit.SECONDS)
+        Future<PredicateGenerator.OrderHandler> second = executor.submit(lookup)
+        boolean secondAnsweredDuringDiscovery = true
+        try {
+            second.get(500, TimeUnit.MILLISECONDS)
+        } catch (TimeoutException ignored) {
+            secondAnsweredDuringDiscovery = false
+        }
+        OrderHandlerDiscoveryProvider.gate.countDown()
+
+        then: "the second caller waited for the discovery, and both callers get the discovered handler"
+        providerEntered
+        !secondAnsweredDuringDiscovery
+        first.get(10, TimeUnit.SECONDS) != null
+        second.get(10, TimeUnit.SECONDS) != null
+
+        cleanup:
+        executor.shutdownNow()
+    }
+
+    void "a handler registered in code is kept over the discovered one"() {
+        given:
+        PredicateGenerator.clearCustomOrderHandlers()
+        PredicateGenerator.OrderHandler registered = { query, root, cb, order, context -> null }
+        PredicateGenerator.registerOrderHandler(OrderHandlerDiscoveryOrder, registered)
+
+        expect:
+        PredicateGenerator.orderHandler(OrderHandlerDiscoveryOrder).is(registered)
+    }
+
+}
+
+class OrderHandlerDiscoveryOrder extends Query.Order {
+
+    OrderHandlerDiscoveryOrder() {
+        super('discovered')
+    }
+
+}
+
+class OrderHandlerDiscoveryProvider implements PredicateGenerator.OrderHandlerProvider {
+
+    static volatile CountDownLatch gate = new CountDownLatch(0)
+    static volatile CountDownLatch entered = new CountDownLatch(0)
+
+    @Override
+    Class<? extends Query.Order> orderType() {
+        OrderHandlerDiscoveryOrder
+    }
+
+    @Override
+    PredicateGenerator.OrderHandler orderHandler() {
+        entered.countDown()
+        gate.await()

Review Comment:
   Done in 54a44543b2: the test provider catches the `InterruptedException`, restores the interrupt flag and fails fast with a clear message.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

Posted by "borinquenkid (via GitHub)" <gi...@apache.org>.
borinquenkid commented on code in PR #16733:
URL: https://github.com/apache/grails-core/pull/16733#discussion_r4363559418


##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/QueryPathContext.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2024-2025 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.orm.hibernate.query;
+
+import jakarta.persistence.criteria.Expression;
+import jakarta.persistence.criteria.From;
+import jakarta.persistence.criteria.Path;
+
+/**
+ * What a criterion or order handler sees of the query it converts for: the root of the query and the resolution
+ * of property paths the way the built-in criteria resolve them. {@code alias.property}, for an alias created with
+ * {@code createAlias}, or {@code association.property} becomes a path on the join GORM created for that
+ * association, so a custom criterion and a built-in one on the same association restrict the same row rather
+ * than each joining the association again.
+ *
+ * @since 8.1
+ */
+public interface QueryPathContext {
+
+    /**
+     * @return the root of the query or subquery the handler converts for
+     */
+    From<?, ?> getRoot();
+
+    /**
+     * @param path a property path: {@code property}, {@code association.property} or {@code alias.property}
+     * @return the path, or {@code null} when the property path resolves to an expression that is not a path
+     */
+    Path<?> getFullyQualifiedPath(String path);
+
+    /**
+     * @param path a property path, or the alias of a projection

Review Comment:
   Reverted in 3bdd02449a, on jdaugherty's analysis in his reply to your second comment: `getFullyQualifiedExpression` resolves as the built-in predicates do, so a projection alias is not folded into it. With `width * 10 as height`, resolving the alias there would make `eq('height', 9)` restrict the projection instead of the column, which SQL does not do (a select alias is visible to `order by`, not to `where`) and neither does Hibernate 5. Your first request, to expose a selection lookup and leave predicate resolution alone, is what `getSelectionAlias` is. An order handler asks it first and `getFullyQualifiedExpression` second, and then orders exactly as `order(alias)` does, for `scaled` (no such property) and for `height` (a property). The javadoc and the guide say so, and `HibernateCriteriaBuilderSqlProjectionSpec` pins it, including that `eq('height', 9)` restricts the property.
   



##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JpaQueryContext.java:
##########
@@ -173,6 +175,7 @@ public Expression<?> getAliasedExpression(String alias) {
         return expr;
     }
 
+    @Override
     public Expression<?> getFullyQualifiedExpression(String path) {

Review Comment:
   Reverted in 3bdd02449a, on jdaugherty's analysis in his reply to your second comment: `getFullyQualifiedExpression` resolves as the built-in predicates do, so a projection alias is not folded into it. With `width * 10 as height`, resolving the alias there would make `eq('height', 9)` restrict the projection instead of the column, which SQL does not do (a select alias is visible to `order by`, not to `where`) and neither does Hibernate 5. Your first request, to expose a selection lookup and leave predicate resolution alone, is what `getSelectionAlias` is. An order handler asks it first and `getFullyQualifiedExpression` second, and then orders exactly as `order(alias)` does, for `scaled` (no such property) and for `height` (a property). The javadoc and the guide say so, and `HibernateCriteriaBuilderSqlProjectionSpec` pins it, including that `eq('height', 9)` restricts the property.
   



##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JpaQueryContext.java:
##########
@@ -173,6 +175,7 @@ public Expression<?> getAliasedExpression(String alias) {
         return expr;
     }
 
+    @Override
     public Expression<?> getFullyQualifiedExpression(String path) {

Review Comment:
   Done in 3bdd02449a: the resolver is back to what it was, and `QueryPathContext.getFullyQualifiedExpression` documents which aliases it resolves and points to `getSelectionAlias` for the column alias of a `sqlProjection` or `sqlGroupProjection`. The guide's order-handler paragraph says to ask `getSelectionAlias` first and `getFullyQualifiedExpression` second, and that a criterion handler asks the second alone. The new feature in `HibernateCriteriaBuilderSqlProjectionSpec` runs your two cases (`scaled`, which no property has, and `height`, which one has) and the `eq('height', 9)` that must restrict the column.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

Posted by "borinquenkid (via GitHub)" <gi...@apache.org>.
borinquenkid commented on PR #16733:
URL: https://github.com/apache/grails-core/pull/16733#issuecomment-6353298342

   Pushed 1e47f7ed5d, from jamesfredley's review on #16696: `QueryPathContext` now exposes `getSelectionAlias(String)`, so an order handler can order by the expression a `sqlProjection` records under its column alias; predicate property resolution is unchanged. `HibernateCriteriaBuilderSqlProjectionSpec` orders by a `sqlProjection` alias through a handler and asserts the rows come in the projection's order and the SQL orders by the select item (`order by 1 desc`), not by a column. The guide names the accessor.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

Posted by "jamesfredley (via GitHub)" <gi...@apache.org>.
jamesfredley commented on code in PR #16733:
URL: https://github.com/apache/grails-core/pull/16733#discussion_r4355313996


##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JpaQueryContext.java:
##########
@@ -173,6 +175,7 @@ public Expression<?> getAliasedExpression(String alias) {
         return expr;
     }
 
+    @Override
     public Expression<?> getFullyQualifiedExpression(String path) {

Review Comment:
   `getFullyQualifiedExpression('total')` still asks only the property resolver. The `sqlProjection` alias is recorded with `registerSelectionAlias`, so this call returns null, or an entity property named `total`. The context javadoc says this method accepts the alias of a projection.
   
   Return the recorded selection when the path is that alias. Please order through `getFullyQualifiedExpression('total')`, not only `getSelectionAlias`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16733:
URL: https://github.com/apache/grails-core/pull/16733#issuecomment-6351794451

   ## 🚨 All tests passed but jobs failed 🚨
   
   ### Failed Jobs without Test Failures
   
   ❌ [Running Copilot Code Review / copilot-pull-request-reviewer](https://github.com/apache/grails-core/actions/runs/39833280603/job/120014859861?pr=16733)
   
   🏷️ Commit: 66f1f26e20776b349f0addfe41b5a08c618ba39c
   ▢️ Tests:  97891 executed
   🟑 Checks: 92/96 completed
   
   ### Rerun Controls
   
   Click the checkbox to trigger a rerun:
   
   πŸ”² **Rerun jobs**
   
   ---
   _Learn more about TestLens at [testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16733:
URL: https://github.com/apache/grails-core/pull/16733#issuecomment-6355943554

   ## 🚨 TestLens detected 94 failed tests 🚨
   
   ### Test Summary
   > [!TIP]
   > Inspect all details with the [TestLens CLI](https://testlens.app/docs/features/cli): `testlens pr 16733`
   
   #### [Groovy Snapshot Canary Build / Build Grails \(shard 0\)](https://github.com/apache/grails-core/actions/runs/39869682983/job/120169061290?pr=16733) > :grails-test-examples-mongodb-hibernate5:test
   
   | Test | Runs | Flakiness |
   |---|---|--:|
   | BookFongoSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   
   #### [Groovy Snapshot Canary Build / Build Grails \(shard 1\)](https://github.com/apache/grails-core/actions/runs/39869682983/job/120169061340?pr=16733) > :grails-data-mongodb-core:test (first 40 of 85)
   
   | Test | Runs | Flakiness |
   |---|---|--:|
   | AggregateMethodSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | AssignedIdentifierSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | AttachMethodSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | AutowireServicesSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | BasicArraySpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | BatchUpdateDeleteSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | BeforeInsertUpdateSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | BeforeUpdatePropertyPersistenceSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | BuildIndexAsyncResultSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | BuildIndexesAsyncSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | BuildIndexesClassificationCostSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | BuildIndexesEnabledByDefaultSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | BuiltinUniqueConstraintWorksWithTargetProxiesConstraintsSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | CircularOneToManySpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | CommonTypesPersistenceSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | ConnectsWhenStartedSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | ConstraintsSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | CriteriaBuilderSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | CrossLayerMultiDataSourceSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | CrossLayerMultiTenantMultiDataSourceSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | CrudOperationsSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | DataServiceConnectionRoutingSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | DataServiceMultiTenantConnectionRoutingSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | DeleteAllSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | DetachedCriteriaSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | DirtyCheckEmbeddedCollectionSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | DirtyCheckingAfterListenerSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | DirtyCheckingSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | DisableAutotimeStampSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | DomainEventsSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | DomainMultiDataSourceSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | DomainMultiTenantMultiDataSourceSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | EnumSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | EventsSetupSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | FailOnErrorSetupSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | FindByExampleSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | FindByMethodSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | FindNativeSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | FindOrCreateWhereSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | FindOrSaveWhereSpec | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   
   #### [Groovy Snapshot Canary Build / Build Grails \(shard 1\)](https://github.com/apache/grails-core/actions/runs/39869682983/job/120169061340?pr=16733) > :grails-test-examples-mongodb-test-data-service:integrationTest
   
   | Test | Runs | Flakiness |
   |---|---|--:|
   | StudentServiceSpec > test regular service autowire by type in a Data Service | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | TestServiceSpec > test autowire by name works | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | TestServiceSpec > test autowire by type | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | TestServiceSpec > test data-service is loaded correctly | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   | TestServiceSpec > test that there is only one bookService | ❌ | [1%&nbsp;🟑](https://github.com/apache/grails-core/issues/16030) |
   
   #### [Groovy Snapshot Canary Build / Build Grails \(shard 2\)](https://github.com/apache/grails-core/actions/runs/39869682983/job/120169061225?pr=16733) > :grails-data-mongodb-spring-boot:test
   
   | Test | Runs | Flakiness |
   |---|---|--:|
   | MongoDbGormAutoConfigurationDiscoverySpec | ❌ | 0%&nbsp;🟒 |
   | MongoDbGormAutoConfigurationSpec | ❌ | 0%&nbsp;🟒 |
   | MongoDbGormAutoConfigureWithGeoSpacialSpec | ❌ | 0%&nbsp;🟒 |
   
   🏷️ Commit: 1e47f7ed5d5986dbd8694e9530e108a4610878e1
   ▢️ Tests:  117451 executed
   🟑 Checks: 95/97 completed
   
   ### Test Failures (first 10 of 93)
   
   <details><summary><strong>BookFongoSpec</strong> (:grails-test-examples-mongodb-hibernate5:test in <a href="https://github.com/apache/grails-core/actions/runs/39869682983/job/120169061290?pr=16733">Groovy Snapshot Canary Build / Build Grails (shard 0)</a>)</summary>
   
   ```
   org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mongo:8.0
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:346)
   	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:317)
   	at functional.tests.EmbeddedMongoClient$Trait$Helper.createMongoClient(EmbeddedMongoClient.groovy:33)
   	at grails.test.mongodb.MongoSpec.setupSpec(MongoSpec.groovy:117)
   Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
   	... 3 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:551)
   	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:341)
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
   	... 4 more
   Caused by: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:520)
   	... 6 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '(?i).*waiting for connections.*'
   	at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:47)
   	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
   	at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:904)
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:487)
   	... 6 more
   ```
   
   </details>
   <details><summary><strong>AggregateMethodSpec</strong> (:grails-data-mongodb-core:test in <a href="https://github.com/apache/grails-core/actions/runs/39869682983/job/120169061340?pr=16733">Groovy Snapshot Canary Build / Build Grails (shard 1)</a>)</summary>
   
   ```
   org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mongo:8.0
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:346)
   	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:317)
   	at org.apache.grails.data.mongo.core.GrailsDataMongoTckManager.setupSpec(GrailsDataMongoTckManager.groovy:80)
   	at org.apache.grails.data.testing.tck.base.GrailsDataTckSpec.setupSpec(GrailsDataTckSpec.groovy:40)
   Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
   	... 3 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:551)
   	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:341)
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
   	... 4 more
   Caused by: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:520)
   	... 6 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '(?i).*waiting for connections.*'
   	at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:47)
   	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
   	at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:904)
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:487)
   	... 6 more
   ```
   
   </details>
   <details><summary><strong>AssignedIdentifierSpec</strong> (:grails-data-mongodb-core:test in <a href="https://github.com/apache/grails-core/actions/runs/39869682983/job/120169061340?pr=16733">Groovy Snapshot Canary Build / Build Grails (shard 1)</a>)</summary>
   
   ```
   org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mongo:8.0
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:346)
   	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:317)
   	at org.apache.grails.data.mongo.core.GrailsDataMongoTckManager.setupSpec(GrailsDataMongoTckManager.groovy:80)
   	at org.apache.grails.data.testing.tck.base.GrailsDataTckSpec.setupSpec(GrailsDataTckSpec.groovy:40)
   Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
   	... 3 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:551)
   	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:341)
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
   	... 4 more
   Caused by: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:520)
   	... 6 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '(?i).*waiting for connections.*'
   	at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:47)
   	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
   	at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:904)
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:487)
   	... 6 more
   ```
   
   </details>
   <details><summary><strong>AttachMethodSpec</strong> (:grails-data-mongodb-core:test in <a href="https://github.com/apache/grails-core/actions/runs/39869682983/job/120169061340?pr=16733">Groovy Snapshot Canary Build / Build Grails (shard 1)</a>)</summary>
   
   ```
   org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mongo:8.0
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:346)
   	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:317)
   	at org.apache.grails.data.mongo.core.GrailsDataMongoTckManager.setupSpec(GrailsDataMongoTckManager.groovy:80)
   	at org.apache.grails.data.testing.tck.base.GrailsDataTckSpec.setupSpec(GrailsDataTckSpec.groovy:40)
   Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
   	... 3 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:551)
   	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:341)
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
   	... 4 more
   Caused by: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:520)
   	... 6 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '(?i).*waiting for connections.*'
   	at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:47)
   	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
   	at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:904)
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:487)
   	... 6 more
   ```
   
   </details>
   <details><summary><strong>AutowireServicesSpec</strong> (:grails-data-mongodb-core:test in <a href="https://github.com/apache/grails-core/actions/runs/39869682983/job/120169061340?pr=16733">Groovy Snapshot Canary Build / Build Grails (shard 1)</a>)</summary>
   
   ```
   org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mongo:8.0
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:346)
   	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:317)
   	at org.apache.grails.data.mongo.core.GrailsDataMongoTckManager.setupSpec(GrailsDataMongoTckManager.groovy:80)
   	at org.apache.grails.data.testing.tck.base.GrailsDataTckSpec.setupSpec(GrailsDataTckSpec.groovy:40)
   Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
   	... 3 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:551)
   	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:341)
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
   	... 4 more
   Caused by: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:520)
   	... 6 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '(?i).*waiting for connections.*'
   	at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:47)
   	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
   	at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:904)
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:487)
   	... 6 more
   ```
   
   </details>
   <details><summary><strong>BasicArraySpec</strong> (:grails-data-mongodb-core:test in <a href="https://github.com/apache/grails-core/actions/runs/39869682983/job/120169061340?pr=16733">Groovy Snapshot Canary Build / Build Grails (shard 1)</a>)</summary>
   
   ```
   org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mongo:8.0
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:346)
   	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:317)
   	at org.apache.grails.data.mongo.core.GrailsDataMongoTckManager.setupSpec(GrailsDataMongoTckManager.groovy:80)
   	at org.apache.grails.data.testing.tck.base.GrailsDataTckSpec.setupSpec(GrailsDataTckSpec.groovy:40)
   Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
   	... 3 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:551)
   	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:341)
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
   	... 4 more
   Caused by: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:520)
   	... 6 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '(?i).*waiting for connections.*'
   	at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:47)
   	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
   	at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:904)
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:487)
   	... 6 more
   ```
   
   </details>
   <details><summary><strong>BatchUpdateDeleteSpec</strong> (:grails-data-mongodb-core:test in <a href="https://github.com/apache/grails-core/actions/runs/39869682983/job/120169061340?pr=16733">Groovy Snapshot Canary Build / Build Grails (shard 1)</a>)</summary>
   
   ```
   org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mongo:8.0
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:346)
   	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:317)
   	at org.apache.grails.data.mongo.core.GrailsDataMongoTckManager.setupSpec(GrailsDataMongoTckManager.groovy:80)
   	at org.apache.grails.data.testing.tck.base.GrailsDataTckSpec.setupSpec(GrailsDataTckSpec.groovy:40)
   Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
   	... 3 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:551)
   	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:341)
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
   	... 4 more
   Caused by: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:520)
   	... 6 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '(?i).*waiting for connections.*'
   	at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:47)
   	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
   	at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:904)
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:487)
   	... 6 more
   ```
   
   </details>
   <details><summary><strong>BeforeInsertUpdateSpec</strong> (:grails-data-mongodb-core:test in <a href="https://github.com/apache/grails-core/actions/runs/39869682983/job/120169061340?pr=16733">Groovy Snapshot Canary Build / Build Grails (shard 1)</a>)</summary>
   
   ```
   org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mongo:8.0
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:346)
   	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:317)
   	at org.apache.grails.data.mongo.core.GrailsDataMongoTckManager.setupSpec(GrailsDataMongoTckManager.groovy:80)
   	at org.apache.grails.data.testing.tck.base.GrailsDataTckSpec.setupSpec(GrailsDataTckSpec.groovy:40)
   Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
   	... 3 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:551)
   	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:341)
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
   	... 4 more
   Caused by: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:520)
   	... 6 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '(?i).*waiting for connections.*'
   	at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:47)
   	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
   	at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:904)
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:487)
   	... 6 more
   ```
   
   </details>
   <details><summary><strong>BeforeUpdatePropertyPersistenceSpec</strong> (:grails-data-mongodb-core:test in <a href="https://github.com/apache/grails-core/actions/runs/39869682983/job/120169061340?pr=16733">Groovy Snapshot Canary Build / Build Grails (shard 1)</a>)</summary>
   
   ```
   org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mongo:8.0
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:346)
   	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:317)
   	at org.apache.grails.data.mongo.core.GrailsDataMongoTckManager.setupSpec(GrailsDataMongoTckManager.groovy:80)
   	at org.apache.grails.data.testing.tck.base.GrailsDataTckSpec.setupSpec(GrailsDataTckSpec.groovy:40)
   Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
   	... 3 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:551)
   	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:341)
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
   	... 4 more
   Caused by: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:520)
   	... 6 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '(?i).*waiting for connections.*'
   	at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:47)
   	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
   	at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:904)
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:487)
   	... 6 more
   ```
   
   </details>
   <details><summary><strong>BuildIndexAsyncResultSpec</strong> (:grails-data-mongodb-core:test in <a href="https://github.com/apache/grails-core/actions/runs/39869682983/job/120169061340?pr=16733">Groovy Snapshot Canary Build / Build Grails (shard 1)</a>)</summary>
   
   ```
   org.testcontainers.containers.ContainerLaunchException: Container startup failed for image mongo:8.0
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:346)
   	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:317)
   	at org.apache.grails.testing.mongo.MongoContainerHolder.startMongoContainer(MongoContainerHolder.groovy:42)
   	at org.apache.grails.testing.mongo.MongoContainerHolder.getContainer(MongoContainerHolder.groovy:53)
   	at org.apache.grails.testing.mongo.StartMongoGrailsUnitExtension.visitSpec_closure1(StartMongoGrailsUnitExtension.groovy:78)
   	at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:139)
   	at org.spockframework.runtime.model.MethodInfo.invoke(MethodInfo.java:157)
   	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
   Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:88)
   	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:331)
   	... 7 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:551)
   	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:341)
   	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
   	... 8 more
   Caused by: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:520)
   	... 10 more
   Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '(?i).*waiting for connections.*'
   	at org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy.waitUntilReady(LogMessageWaitStrategy.java:47)
   	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
   	at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:904)
   	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:487)
   	... 10 more
   ```
   
   </details>
   
   ### Rerun Controls (first 20 of 94)
   > [!NOTE]
   > Checks are currently running using the configuration below.
   
   Select tests to mute in this pull request:
   
   πŸ”² AggregateMethodSpec <!-- uniqueId=[engine:spock]/[spec:org.grails.datastore.gorm.mongo.AggregateMethodSpec] -->
   πŸ”² AssignedIdentifierSpec <!-- uniqueId=[engine:spock]/[spec:org.grails.datastore.gorm.mongo.AssignedIdentifierSpec] -->
   πŸ”² AttachMethodSpec <!-- uniqueId=[engine:spock]/[spec:org.apache.grails.data.testing.tck.tests.AttachMethodSpec] -->
   πŸ”² AutowireServicesSpec <!-- uniqueId=[engine:spock]/[spec:org.grails.datastore.gorm.mongo.AutowireServicesSpec] -->
   πŸ”² BasicArraySpec <!-- uniqueId=[engine:spock]/[spec:org.grails.datastore.gorm.mongo.BasicArraySpec] -->
   πŸ”² BatchUpdateDeleteSpec <!-- uniqueId=[engine:spock]/[spec:org.grails.datastore.gorm.mongo.BatchUpdateDeleteSpec] -->
   πŸ”² BeforeInsertUpdateSpec <!-- uniqueId=[engine:spock]/[spec:org.grails.datastore.gorm.mongo.BeforeInsertUpdateSpec] -->
   πŸ”² BeforeUpdatePropertyPersistenceSpec <!-- uniqueId=[engine:spock]/[spec:org.grails.datastore.gorm.mongo.BeforeUpdatePropertyPersistenceSpec] -->
   πŸ”² BookFongoSpec <!-- uniqueId=[engine:spock]/[spec:functional.tests.BookFongoSpec] -->
   πŸ”² BuildIndexAsyncResultSpec <!-- uniqueId=[engine:spock]/[spec:org.grails.datastore.gorm.mongo.BuildIndexAsyncResultSpec] -->
   πŸ”² BuildIndexesAsyncSpec <!-- uniqueId=[engine:spock]/[spec:org.grails.datastore.gorm.mongo.BuildIndexesAsyncSpec] -->
   πŸ”² BuildIndexesClassificationCostSpec <!-- uniqueId=[engine:spock]/[spec:org.grails.datastore.gorm.mongo.BuildIndexesClassificationCostSpec] -->
   πŸ”² BuildIndexesEnabledByDefaultSpec <!-- uniqueId=[engine:spock]/[spec:org.grails.datastore.gorm.mongo.BuildIndexesEnabledByDefaultSpec] -->
   πŸ”² BuiltinUniqueConstraintWorksWithTargetProxiesConstraintsSpec <!-- uniqueId=[engine:spock]/[spec:org.apache.grails.data.testing.tck.tests.BuiltinUniqueConstraintWorksWithTargetProxiesConstraintsSpec] -->
   πŸ”² CircularOneToManySpec <!-- uniqueId=[engine:spock]/[spec:org.apache.grails.data.testing.tck.tests.CircularOneToManySpec] -->
   πŸ”² CommonTypesPersistenceSpec <!-- uniqueId=[engine:spock]/[spec:org.apache.grails.data.testing.tck.tests.CommonTypesPersistenceSpec] -->
   πŸ”² ConnectsWhenStartedSpec <!-- uniqueId=[engine:spock]/[spec:grails.mongodb.bootstrap.ConnectsWhenStartedSpec] -->
   πŸ”² ConstraintsSpec <!-- uniqueId=[engine:spock]/[spec:org.apache.grails.data.testing.tck.tests.ConstraintsSpec] -->
   πŸ”² CriteriaBuilderSpec <!-- uniqueId=[engine:spock]/[spec:org.apache.grails.data.testing.tck.tests.CriteriaBuilderSpec] -->
   πŸ”² CrossLayerMultiDataSourceSpec <!-- uniqueId=[engine:spock]/[spec:org.apache.grails.data.testing.tck.tests.CrossLayerMultiDataSourceSpec] -->
   
   Reuse successful test results:
   
   πŸ”² ♻️ Only rerun the tests that failed or were muted before
   
   Click the checkbox to trigger a rerun:
   
   πŸ”² **Rerun jobs**
   
   ---
   _Learn more about TestLens at [testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Hibernate 7: give criterion handlers the query context and let a handler order by an expression (8.1.x) [grails-core]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #16733:
URL: https://github.com/apache/grails-core/pull/16733#issuecomment-6348179913

   ## [Codecov](https://app.codecov.io/gh/apache/grails-core/pull/16733?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 63.3757%. Comparing base ([`8910a5c`](https://app.codecov.io/gh/apache/grails-core/commit/8910a5c8783703fd3393e8a5af06a171c0a5c847?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`66f1f26`](https://app.codecov.io/gh/apache/grails-core/commit/66f1f26e20776b349f0addfe41b5a08c618ba39c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 18 commits behind head on 8.1.x.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/grails-core/pull/16733/graphs/tree.svg?width=650&height=150&src=pr&token=qJrryhpk7u&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/grails-core/pull/16733?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##                8.1.x     #16733        +/-   ##
   ==================================================
   + Coverage     63.3231%   63.3757%   +0.0527%     
   - Complexity      28459      28489        +30     
   ==================================================
     Files            2311       2311                
     Lines          113600     113605         +5     
     Branches        20675      20675                
   ==================================================
   + Hits            71935      71998        +63     
   + Misses          32242      32185        -57     
   + Partials         9423       9422         -1     
   ```
   [see 11 files with indirect coverage changes](https://app.codecov.io/gh/apache/grails-core/pull/16733/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org