Skip to content

fix(hibernate7): preserve subquery projections, fail fast on unresolved paths, and filter nulls in inList - #16818

Open
borinquenkid wants to merge 6 commits into
fix/h7-scalar-subqueries-comparisons-8.0.xfrom
fix/h7-criteria-projection-immutability-8.0.x
Open

borinquenkid wants to merge 6 commits into
fix/h7-scalar-subqueries-comparisons-8.0.xfrom
fix/h7-criteria-projection-immutability-8.0.x

Conversation

@borinquenkid

Copy link
Copy Markdown
Member

Summary

Addresses three criteria translation issues in grails-data-hibernate7-core:

  1. Subquery Projection List Immutability: Populates a local Query.ProjectionList in PropertyCriterionHandler.buildSubquery (and reuses it from SubqueryCriterionHandler) instead of mutating QueryableCriteria.getProjections() in-place.
  2. Fail-Fast on Unresolved Property Paths: Throws ConfigurationException in PropertyComparisonCriterionHandler, PropertyNameCriterionHandler, and SubqueryCriterionHandler when a property path cannot be resolved rather than returning null predicates.
  3. Null Filtering in inList (Query.In): Filters null values from Query.In collections prior to value conversion and returns a disjunction predicate when no non-null values remain.

Note: Chained on #16817 (fix/h7-scalar-subqueries-comparisons-8.0.x).

Fixes #16815

Copilot AI balanced review requested due to automatic review settings November 1, 2026 01:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Regression coverage is incomplete because invalid-path tests bypass the public query API, and function-wrapped In lacks mixed-null, all-null, empty-list, and numeric-conversion test cases.

2 open issues
What changed in this PR

This PR addresses three Hibernate 7 criteria-translation issues from #16815, building on the scalar-subquery support in #16817.

Changes:

  • Copies subquery projections locally and shares subquery construction between handlers.
  • Adds descriptive exceptions for unresolved property paths.
  • Filters null members from plain and function-wrapped IN collections, with regression tests for plain inList, projection immutability, and invalid paths.
File Description
grails-data-hibernate7/​core/​src/​test/​groovy/​grails/​orm/​HibernateCriteriaBuilderDirectSpec.groovy Adds public-query tests for null lists and shared subquery immutability.
grails-data-hibernate7/​core/​src/​test/​groovy/​grails/​gorm/​tests/​hibernatequery/​PredicateGeneratorSpec.groovy Adds translator tests for projections, invalid paths, and null lists.
grails-data-hibernate7/​core/​src/​main/​groovy/​org/​grails/​orm/​hibernate/​query/​SubqueryCriterionHandler.java Validates property paths and reuses shared subquery construction.
grails-data-hibernate7/​core/​src/​main/​groovy/​org/​grails/​orm/​hibernate/​query/​PropertyNameCriterionHandler.java Rejects unresolved property paths.
grails-data-hibernate7/​core/​src/​main/​groovy/​org/​grails/​orm/​hibernate/​query/​PropertyCriterionHandler.java Preserves source projections and handles null or empty IN lists.
grails-data-hibernate7/​core/​src/​main/​groovy/​org/​grails/​orm/​hibernate/​query/​PropertyComparisonCriterionHandler.java Rejects unresolved paths on either comparison operand.
grails-data-hibernate7/​core/​src/​main/​groovy/​org/​grails/​orm/​hibernate/​query/​FunctionCallingCriterionHandler.java Filters nulls and handles empty function-wrapped IN lists.

Review effort: Balanced

@borinquenkid
borinquenkid force-pushed the fix/h7-scalar-subqueries-comparisons-8.0.x branch 2 times, most recently from 25448d5 to 323473b Compare November 1, 2026 16:47
…ed paths, and filter nulls in inList

- Copy subquery projections into a local ProjectionList in PropertyCriterionHandler and SubqueryCriterionHandler instead of mutating the caller's QueryableCriteria in-place
- Throw ConfigurationException when property paths cannot be resolved in PropertyComparisonCriterionHandler, PropertyNameCriterionHandler, and SubqueryCriterionHandler
- Filter null elements in In criteria across PropertyCriterionHandler and FunctionCallingCriterionHandler and return a false predicate (disjunction) when no non-null values remain

Fixes #16815
…-projection-immutability-8.0.x

Takes the merge of fix/h7-where-query-functions-8.0.x, the review changes of #16816.

Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants