jamesfredley commented on code in PR #16696:
URL: https://github.com/apache/grails-core/pull/16696#discussion_r4352459816


##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/QueryPathContext.groovy:
##########
@@ -0,0 +1,50 @@
+/*
+ * 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 10.0
+ */
+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)
+
+    /**

Review Comment:
   A custom order that names a `sqlProjection` alias cannot get that 
expression. The translator records it with `registerSelectionAlias`, and 
`getFullyQualifiedExpression` ignores that map. The lookup returns null, or an 
entity property of the same name.
   
   Expose the selection alias on this context. Do not change predicate property 
resolution. Please order by a `sqlProjection` 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to