Repository navigation
fix(hibernate7): support where-query functions and refactor PredicateGenerator - #16816
borinquenkid wants to merge 35 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved query-generation defects produce invalid IN clauses, mishandle subqueries and null/case-insensitive comparisons, and can select the wrong criterion handler.
6 open issues
Function IN handler treats subqueries as empty value lists · New Function comparisons mishandle null operands · New Handler fallback may select an incompatible superclass handler · New Function-based ILike restrictions are rendered case-sensitively · New Function-based IN ignores subquery operands · New Function-based IN queries render a trailing separator · New
What changed in this PR
This PR addresses #16811 by adding where-query function support to Hibernate 7 and the shared JPA query builder. It also separates predicate generation into dedicated handlers while retaining the custom-handler extension point.
Changes:
- Adds function-based comparisons for string and date properties.
- Extracts criterion handlers and shared evaluation context from
PredicateGenerator. - Adds Hibernate-backed function-query tests and predicate-generation checks.
| File | Description |
|---|---|
| grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/query/jpa/JpaQueryBuilder.java | Adds parameterized function comparisons to generated queries. |
| grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/hibernatequery/PredicateGeneratorSpec.groovy | Tests function predicates and invalid inputs. |
| grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/detachedcriteria/WhereQueryFunctionsSpec.groovy | Tests string and year functions through where-queries. |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/SubqueryCriterionHandler.java | Extracts quantified subquery comparisons. |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/SqlRestrictionCriterionHandler.java | Extracts native SQL restriction handling. |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PropertyNameCriterionHandler.java | Extracts nullness and emptiness checks. |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PropertyCriterionHandler.java | Extracts property comparisons and subquery construction. |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PropertyComparisonCriterionHandler.java | Extracts property-to-property comparisons. |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PredicateGenerator.java | Introduces handler registration, lookup, and dispatch. |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/NotExistsCriterionHandler.java | Extracts negated existence predicates. |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JunctionCriterionHandler.java | Extracts logical predicate combinations. |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/InternalCriterionHandler.java | Defines the internal handler strategy interface. |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/FunctionCallingCriterionHandler.java | Builds function expressions and comparison predicates. |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/ExistsCriterionHandler.java | Extracts existence subquery predicates. |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/CriterionContext.java | Centralizes query state, path resolution, and conversion helpers. |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/AssociationCriterionHandler.java | Extracts association navigation and nested predicate handling. |
Review effort: Balanced
- Add FunctionCallingCriterion handling in JpaQueryBuilder and PredicateGenerator, including null, subquery, and case-insensitive ILike operands - Encapsulate criterion evaluation context and helpers into CriterionContext - Introduce InternalCriterionHandler strategy interface and dedicated criterion delegates - Refactor PredicateGenerator to dispatch criteria via CriterionContext with nearest-superclass fallback lookup - Add WhereQueryFunctionsSpec, JpaQueryBuilderFunctionSpec, and criterion handler coverage in PredicateGeneratorSpec Fixes #16811
89cd64d to
d0ff76b
Compare
…e on H5 and H7 The PredicateGenerator refactor was covered by specs that check the shape of the predicate built, so a wrong operator or a dropped null branch passed. Add integration scenarios to the Hibernate 5 and Hibernate 7 grails-hibernate test apps that execute each comparison, null, in, range, and/or/not criterion through where queries, the criteria builder and dynamic finders, on simple, enum, association and embedded properties, and assert the rows that come back. != and ne include rows whose value is null on Hibernate 7, as the TCK defines; Hibernate 5 leaves them out, as its NullValueEqualSpec documents. Each copy states its own behaviour in the feature name.
…ernate 5 does Hibernate 7 OR-ed an IS NULL into NotEquals, so qty != 2 returned the rows where qty is null. Hibernate 5 maps NotEquals to Restrictions.ne, which is plain SQL and leaves them out. An application moving from Hibernate 5 to Hibernate 7 got different rows for the same query. Match Hibernate 5 for property comparisons, comparisons against a subquery, and function comparisons. The Hibernate 7 copy of NullValueEqualSpec now carries the same documented exception to the TCK that the Hibernate 5 copy has. ne with a null value still means IS NOT NULL; Hibernate 5 turns that into '<> NULL', which matches nothing.
|
For the team: This PR adds integration scenarios to
781d0f3 makes H7 match H5. The H7 Why H5 is the reference, not the TCK line: the TCK assertion Worth sharing with the team
Full |
|
Heads-up for reviewers: #16573 (the |
jdaugherty
left a comment
There was a problem hiding this comment.
Ran this at 781d0f3. The full grails-data-hibernate7-core suite passes, and a throwaway spec run on this head and on 8803d54, on Hibernate 7 and Hibernate 5, confirms the fix: every where-query function the guide documents now runs on Hibernate 7, including year(pets.birthDate), in, null operands, paging and updateAll / deleteAll. The dispatch rewrite keeps the old order: every instanceof target of the old chain is a class, and the nearest-superclass lookup resolves them the way the chain did.
The inline comments are, in order of weight: a spec that expects a query that cannot be parsed, the function name going into the query unchecked, the javadoc of the public SPI, an upgrade note for !=, the visibility of the new types, executed tests for what changes here, and two small ones.
For the rebase onto #16573: only PredicateGenerator.java shows a conflict, but AssociationCriterionHandler is a new file that holds the association code from before that change, so it merges silently. It needs resolveAssociation, the QueryAliasRegistrar context and the null for a block without criteria ported by hand.
| def info = new JpaQueryBuilder(entity, criteria).buildUpdate(age: 30) | ||
|
|
||
| then: | ||
| info.query == "UPDATE ${JpaFunctionTestPerson.name} jpaFunctionTestPerson SET jpaFunctionTestPerson.age=:p1 WHERE (upper(jpaFunctionTestPerson.name) IN (SELECT jpaFunctionTestPerson1.name FROM ${JpaFunctionTestPerson.name} jpaFunctionTestPerson1 WHERE jpaFunctionTestPerson1.name=:p2jpaFunctionTestPerson1.age > :p3) AND lower(jpaFunctionTestPerson.name) = :p4)" |
There was a problem hiding this comment.
The expected query has no AND between the two criteria of the subquery (...name=:p2jpaFunctionTestPerson1.age > :p3), so this pins a query that Hibernate cannot parse. Executed at this head, inList('name', sub) with two criteria in sub, followed by updateAll, throws a SyntaxException on Hibernate 7 and a QuerySyntaxException on Hibernate 5, and a subquery without criteria renders WHERE ).
buildSubQuery appends the criteria with nothing between them. This PR already changes that loop to carry position, so please join them here as well: #16822 (e036996) does it with buildWhereClauseForCriterion and a Query.Conjunction, and leaves WHERE out for an empty list. Then this expectation can be a query that runs. If that change stays in #16822, give this stub a single criterion so the spec does not assert broken output until then.
| parameters.add(wrapped.getValue()); | ||
| return position; | ||
| } | ||
| whereClause.append(functionCriterion.getFunctionName()) |
There was a problem hiding this comment.
The property goes through validateProperty, but the function name is appended to the query as it is. On Hibernate 5, list() looks the name up in the dialect and rejects one it does not know (Unsupported function defined in query [x]). Here a FunctionCallingCriterion whose function name is not a plain identifier changes the WHERE clause: in a probe it made updateAll update every row, on Hibernate 5 and on Hibernate 7. The same holds for list() on Hibernate 7, where the default branch of FunctionCallingCriterionHandler.applyFunction hands any name to criteriaBuilder.function.
That branch also types every other function as Integer, so a function that returns a string fails with a ConversionFailedException on the value it is compared with.
Please accept only the ten functions the where DSL supports (SUPPORTED_FUNCTIONS in DetachedCriteriaTransformer) in both places, or at least require a plain identifier, and throw InvalidDataAccessResourceUsageException for anything else, as Hibernate 5 does.
| * | ||
| * @since 8.0 | ||
| * @author Graeme Rocher | ||
| * @since 6.0 |
There was a problem hiding this comment.
PredicateGenerator was added for Hibernate 7 (52e87b8), and 841f6fb set @since 8.0 on it on purpose. Please keep that rather than @author Graeme Rocher / @since 6.0.
The rewrite also drops the javadoc of the public SPI, which is the only documentation it has on 8.0.x (the guide does not cover it):
CriterionHandler: registered handlers run before the built-in handling and can override it. The example that is left no longer compiles, sincecis undefined without thedef c = criterion as MyCustomCriterionline.CriterionHandlerProvider: theMETA-INF/services/org.grails.orm.hibernate.query.PredicateGenerator$CriterionHandlerProviderfile name and the example.registerCriterionHandler: the type has to match exactly, and a programmatic registration wins over aServiceLoaderone.clearCustomCriterionHandlers.
The comments that explain the moved code are gone as well: convertComparisonValue (why a plain value is not wrapped in a literal, which is what keeps comparisons on a UserType property working), asExpression, handleEqualsIgnoreCase, aliasColumn and nativeSqlArguments. Please carry them over to where the code lives now.
| Subquery<?> subquery = buildSubquery(context, propertyPath, qc, pc.getProperty()); | ||
| return criteriaBuilder.notEqual(propertyPath, subquery); | ||
| } | ||
| return criteriaBuilder.notEqual(propertyPath, context.convertComparisonValue(pc.getProperty(), value, propertyPath)); |
There was a problem hiding this comment.
On the question for the team: I agree with leaving the null rows out. At 8803d54 the same where query picked different rows depending on the operation. With qty null on one row, where { qty != 2 }.list(), count(), ne 'qty', 2 and findAllByQtyNotEqual(2) returned that row, while where { qty != 2 }.updateAll(..) and deleteAll() left it alone (JpaQueryBuilder renders a plain !=), and so did !(qty == 2), not { eq 'qty', 2 }, !(qty in [2]) and findAllByQtyNotInList([2]). With this commit they all agree.
It does change the rows an application on 8.0.0 gets back from !=, ne and the NotEqual finders, also inside an ||. Please add a section to upgrading80x.adoc ("As of Grails 8.0.1 ...") that says so and shows how to keep the null rows (qty != 2 || qty == null), and a sentence next to != / ne in the Hibernate 7 whereQueries.adoc and criteria docs.
| * @since 8.0.1 | ||
| */ | ||
| @FunctionalInterface | ||
| public interface InternalCriterionHandler<T extends Query.QueryElement> { |
There was a problem hiding this comment.
InternalCriterionHandler, CriterionContext and the ten handler classes are public types with public constructors and static methods, new in a patch release. Nothing outside org.grails.orm.hibernate.query uses them (the specs go through PredicateGenerator), so they can be package-private, as QueryAliasRegistrar is. That keeps them free to change, and it avoids a second public context type next to QueryPathContext, which 8.1.x already hands to custom handlers.
Optional: findHandler walks the superclass chain, so registering PropertyCriterion, SubqueryCriterion, PropertyNameCriterion, PropertyComparisonCriterion and Junction covers their subclasses. The 42 entries for the subclasses each create another handler instance and change nothing.
| matches == ['a', 'b'] | ||
| } | ||
|
|
||
| void "bulk updateAll and deleteAll support function IN, ILike, and subquery criteria"() { |
There was a problem hiding this comment.
This feature runs two updateAll calls; there is no deleteAll and no subquery in it. Several things this PR changes are covered only by specs that compare query strings or count predicates. All of them pass when executed, so this is about pinning them:
deleteAllwith a function, and a functioninover a subquery in a bulk operation.- Parameter positions after a subquery in a bulk operation:
inList('name', sub); eq('qty', 1)followed byupdateAllfails at 8803d54 (SemanticExceptionon Hibernate 7,Could not locate named parameter [p3]on Hibernate 5) and works here, fornotIntoo. That fix reaches Hibernate 5, which has no executed test for it. ==and!=against a projected subquery, such aswhere { qty == max(qty) }: aClassCastExceptionat 8803d54, right here becausebuildSubquerynow hands the subquery's projections to the creator.PredicateGeneratorSpeconly checkspredicates.length == 13for it.- The association form the guide documents,
year(pets.birthDate) == 2009, andmonth,day,hour,minuteandsecond.
| if (wrapped instanceof Query.LessThanEquals) { | ||
| return " <= "; | ||
| } | ||
| if (wrapped instanceof Query.Like) { |
There was a problem hiding this comment.
RLike extends Like, so a function over an rlike is rendered as LIKE in a bulk query: lower(name) with rlike '^r.x$' matches a row through list() and updates none through updateAll. A plain RLike is rejected there as unsupported; returning null for it here does the same.
| names(rows) == ['a', 'c'] | ||
| } | ||
|
|
||
| void "where: negation follows SQL three-valued logic, unlike != which includes null rows"() { |
There was a problem hiding this comment.
The name still says != includes null rows. The Hibernate 5 copy has the same line.
jamesfredley
left a comment
There was a problem hiding this comment.
A where query can call a function in a comparison, and a non-null != comparison leaves out nulls, as Hibernate 5 does. Not approving. updateAll and deleteAll write a regular expression as LIKE, and they bind a one-row subquery as a parameter instead of rendering it.
| if (wrapped instanceof Query.LessThanEquals) { | ||
| return " <= "; | ||
| } | ||
| if (wrapped instanceof Query.Like) { |
There was a problem hiding this comment.
A function around an rlike comparison, then deleteAll(), deletes nothing when the name matches the regular expression. RLike is a Like, so this branch emits LIKE. Handle the regular expression before this branch. A read of the same criterion already uses the regular expression.
| throw new InvalidDataAccessResourceUsageException("Unsupported criterion in a function call: " + wrapped.getClass().getSimpleName()); | ||
| } | ||
| whereClause.append(operator).append(PARAMETER_PREFIX).append(++position); | ||
| parameters.add(wrapped.getValue()); |
There was a problem hiding this comment.
A function around an equality whose value is a one-row detached criteria, then deleteAll(), binds the criteria object as the parameter and the update fails. Render that value as a subquery, as the read path does.
The association code that #16573 changed in PredicateGenerator now lives in AssociationCriterionHandler: a block resolves its association through the context, takes the context of a QueryAliasRegistrar, and yields no predicate when it has no criteria. Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
…orted functions and render a subquery value in a bulk statement A subquery in a bulk statement wrote its criteria one after another with nothing between them, so a subquery with two criteria did not parse and one with none ended in WHERE. The criteria are joined with AND and WHERE is left out for none. A function name was written into the statement as it was given, so a name that was not an identifier changed the WHERE clause of updateAll and deleteAll, and Hibernate 7 passed any name to the database. Only the ten functions the where DSL accepts are run, in the bulk statement and in Hibernate 7, and any other name throws InvalidDataAccessResourceUsageException. The list is declared once, in FunctionCallingCriterion, and the DSL transform uses it. A function over an rlike was written as LIKE in a bulk statement, which matched differently from the read of the same criterion. A bulk statement has no regular expression operator, so it is rejected, as a plain rlike is. A function over an equality or a comparison with a one-row detached criteria bound the criteria object as the parameter. The criteria is written as a subquery, as the read does. Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
…ed paths, and filter nulls in inList (#16818) * fix(hibernate7): preserve subquery projections, fail fast on unresolved 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 * test(hibernate): run inList with nulls, reused subquery criteria and unknown properties on H5 and H7 Claude-Session: https://claude.ai/code/session_01Dmki4SQGwRSj8pRJ5KCWyX
The only conflict is the numbering of the upgrade guide: the sections 26.11 to 26.14 of this branch are kept after 26.10. Also, for the review of the branch: - the protected buildSubQuery overload that takes the compared property is private, since only JpaQueryBuilder calls it; - FunctionComparison and the public static members of FunctionCallingCriterion say they are internal to GORM; - the upgrade note on not-equal comparisons says it restores the result of Hibernate 5 and of Grails 7 on Hibernate 7. Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
…16821 Preserving the failure of an unresolved property comparison in a subquery (#16818) makes the feature that compares with a path on the root alias of the enclosing query fail where the comparison used to be dropped without an error. #16821 registers the root alias and rewrites the feature; #16884 tracks it. Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
|
Thank you, all six are done in the new commits: d8f0b90 (#16818), 7499148 (merge of 8.0.x) and 895101b.
The tests of |
jamesfredley
left a comment
There was a problem hiding this comment.
Requested changes. A negated in list that contains null no longer means what SQL means.
…as on Hibernate 5 ne no longer returns rows whose value is null on Hibernate 7 (matching Hibernate 5), so a club without a team is left out of ne on a property of a left alias, as on Hibernate 5 (#16905). The scenario merged in #16907 expected the earlier behaviour. Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
|
CI on 895101b had one failure on every failing job: The branch also merges 8.0.x (no conflicts) so the run is on a current base. Everything else in the run passed. |
Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL # Conflicts: # grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/FunctionCallingCriterionHandler.java # grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PropertyCriterionHandler.java # grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/query/jpa/JpaQueryBuilder.java
jamesfredley
left a comment
There was a problem hiding this comment.
Requested changes. A negated in list that contains null still does not mean what SQL means.
…p the registry layout feature The merge of #16816 had added null filtering for a function's in list and a disjunction for an empty one in FunctionComparison and FunctionCallingCriterionHandler. Neither parent has it, so it goes back to #16816's version of both files; a function's list follows whatever #16816 decides for a plain in. PredicateGeneratorHandlerRegistrySpec no longer has the feature that pins how the registration map is laid out, which no query depends on. Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
|
The note "Not-Equal Comparisons Leave Out Null Rows" is now in the Grails 8.0.1 section of |
matrei
left a comment
There was a problem hiding this comment.
Round 2, reviewed at caf243f. Thanks for the quick turnaround. CI passes at caf243f.
Round 1
- #16818: d8f0b90 is 10531d1 except for the
FunctionCallingCriterionHandlerhunk, where this branch'sFunctionComparisonpath is kept (I compared them withgit range-diff). On the pendingSubqueryAliasSpecfeature: 8.0.x today drops the comparison with the root alias and returns both teams, and this branch throws aConfigurationExceptioninstead. That is the better failure, but #16816 and #16821 should go out in the same release. - CI and the conflict: done.
- Branch: done as #17049, which I'll review on its own.
- Description: done, apart from one line that changes with item A below.
- API: done. The changes are in the merge commit 7499148, not in a commit of their own, which makes them easy to miss, but they are right.
- Upgrade note: done, and it's now in the 8.0.1 section.
Needs a fix
A. A negated in with a null in the list (James's point). He's right. I ran the forms on Hibernate 5 on 7.0.x, on Hibernate 7 on 8.0.x and at this head, with three rows: qty 1, 2 and null.
| Query | Hibernate 5, 7.0.x | Hibernate 7, 8.0.x | This head |
|---|---|---|---|
where { qty in [1, null] }, inList, findAllByQtyInList |
[one] |
ConfigurationException |
[one] |
where { !(qty in [1, null]) }, not { inList(...) }, findAllByQtyNotInList([1, null]) |
[] |
ConfigurationException |
[two] |
where { !(qty in [null]) } |
[] |
ConfigurationException |
[none, one, two] |
where { !(qty in [1, null]) }.updateAll(...) |
0 rows | 0 rows | 0 rows |
where { !(qty in [null]) }.updateAll(...) |
0 rows | 0 rows | 0 rows |
where { !(lower(name) in ['one', null]) } |
lower not supported |
UnsupportedOperationException |
[] |
On 8.0.x a null anywhere in the list throws, which is a regression from Grails 7, so fixing it here is right. But dropping the null restores the Hibernate 5 result only for in, not for its negations:
!(qty in [null])returns the row whoseqtyisnull. That contradicts the PR's own upgrade note, which says a not-equal comparison leaves those rows out.- The read and the bulk statement of the same where query disagree again.
list()returnstwo, butupdateAllchanges no row, becauseJpaQueryBuilderkeeps thenull. The note says that mismatch is gone.
The function path of this PR already keeps the null, and gives SQL's result (last row). Please keep the null in PropertyCriterionHandler.handleIn too, so that SQL decides there, as it does on Hibernate 5, in the bulk statements and for the functions. Also add the negated forms to CriteriaInListScenarioSpec, in both example applications. The description's "nulls filtered out of an in list" then becomes "a null in an in list no longer throws".
Should fix
B. The ne scenario through a left alias (2c6b447). @PendingFeature marks the expectation as the result we want, but this one says "a missing association matches ne", which is what this PR decides against. With the PR, Hibernate 5's result is the reference for ne, as your correction on #16905 says. So the feature in both example applications should expect ['c2', 'c3'] for ne and for not { eq }, without @PendingFeature, and get a name to match. That also answers point 2 of #16905.
Verified
- The
!=change:qty != 2,ne('qty', 2)andfindAllByQtyNotEqual(2)return[one]on Hibernate 5 on 7.0.x and at this head, and[none, one]on 8.0.x.!(qty == 2),not { eq(...) }andfindAllByQtyNotInList([2])return[one]on all three. - A
nullin a positivein, and an empty list: they give the Hibernate 5 result.!(qty in [])returns every row on all three.
…result for ne through a left alias A null in an in list stays in the list, as it does on Hibernate 5 and in the bulk statements, so SQL decides what it matches: a negated list that holds a null matches no row, the read and the bulk statement of the same where query agree, and a negated empty list still matches every row. The ne scenario through a left alias in both example applications expects c2 and c3, as Hibernate 5 returns, and is no longer pending. Claude-Session: https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL
|
@matrei: round 2. A. B. The |
jamesfredley
left a comment
There was a problem hiding this comment.
The items this review found have been addressed. A negated in list that contains null keeps the null.
# Conflicts: # grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/query/jpa/JpaQueryBuilder.java
|
Merged 8.0.x into this branch, which clears the conflict in |
✅ All tests passed ✅🏷️ Commit: c4d2c24 Learn more about TestLens at testlens.app/docs. |
… in) into fix/h7-subquery-root-alias-nested-paths-8.0.x # Conflicts: # grails-doc/src/en/guide/upgrading/upgrading80x.adoc

Summary of Changes
lower,upper,trim,length,second,hour,minute,day,month,year) runs on Hibernate 7, in a read and in the bulk statementsupdateAllanddeleteAll.WhereQueryFunctionsSpeccovers the string and date functions,in, null operands, paging and the bulk statements.CriterionContext,InternalCriterionHandleris the strategy interface, and each criterion has a package-private handler.PredicateGeneratordispatches through a concurrent map and the nearest-superclass lookup, as theinstanceofchain it replaces did, and keeps the public SPI (CriterionHandler,CriterionHandlerProvider,CUSTOM_HANDLERS,registerCriterionHandler,clearCustomCriterionHandlers).inList(fix(hibernate7): preserve subquery projections, fail fast on unresolved paths, and filter nulls in inList #16818): a comparison of a property or function with a scalar subquery, a subquery without projection compared by the property it names, an unresolved property comparison failing with aConfigurationExceptioninstead of being dropped, and anullin aninlist no longer throws.Results that change, and how to keep the old ones
!=,neand theNotEqualfinders leave out the rows whose value isnullon Hibernate 7, as Hibernate 5 always has and as Grails 7 did (upgrade note 26.14).qty != 2 || qty == nullkeeps them.AND, the parameter positions after a subquery are right, an emptyINlist is written as a condition that matches nothing, and a subquery without projection is compared by the property of the function.rlikeis rejected in a bulk statement.ConfigurationException; before, it was dropped. The feature that compares with a path on the root alias of the enclosing query (SubqueryAliasSpec, H7 SubqueryAliasSpec 'root alias' fails on the PredicateGenerator chain until #16821 #16884) is marked pending until Fix root alias registration and nested alias path resolution in subqueries #16821 registers the root alias.There is no setting that restores the old result of these: each of them contradicted the call.
Verification
The tests of
grails-datastore-core,grails-datamapping-core,grails-data-hibernate5-coreandgrails-data-hibernate7-corepass, andcodeStylepasses.https://claude.ai/code/session_01Dmki4RzWwreEC2GkkyFnvL