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

   Fixes #16633
   
   Based on 8.0.x; independent of the stacked PRs.
   
   Under Hibernate 7, calling a collection criterion such as 
`isNotEmpty('pets')`, `isEmpty('pets')`, or `sizeEq('pets', n)` next to an 
association block for the same collection (`pets { ... }`) threw 
`ClassCastException`:
   
   ```
   java.lang.ClassCastException: class 
org.hibernate.query.sqm.tree.domain.SqmSetJoin cannot be cast to class 
org.hibernate.query.sqm.tree.domain.SqmPluralValuedSimplePath
   ```
   
   Hibernate 7's `SqmCriteriaNodeBuilder.isEmpty` / `isNotEmpty` cast the 
collection expression directly to `SqmPluralValuedSimplePath`, which represents 
the plural attribute on the parent table group. When the association is joined 
in the same criteria query, resolving `'pets'` against the query context 
returned the `Join` (`SqmSetJoin`) instead of the collection attribute on the 
parent.
   
   **Fix:**
   In `PredicateGenerator`, unwraps any `Join` expression to its parent's 
collection attribute (`join.getParent().get(join.getAttribute().getName())`) 
before passing it to collection criteria (`isEmpty`, `isNotEmpty`, `size*`, 
`isMember`).
   
   **Tests:**
   - Added `CollectionCriterionAssociationBlockSpec` with top-level and nested 
criteria combinations (association block before criterion, criterion before 
association block, `isEmpty`, `sizeEq`, and `sizeGt`).
   - Verified mutation check: failing with `ClassCastException` without the 
fix, passing with the fix.
   
   Docs: upgrade note in `upgrading80x.adoc`.
   


-- 
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