Repository navigation
Replace finders inheritance hierarchy with composition - #16154
Conversation
The 4-level DynamicFinder inheritance chain (AbstractFinder -> DynamicFinder -> AbstractFindByFinder -> concrete finders) made FindOrSaveByFinder carry dead code: its own copy of the construct-from-Equal-expressions logic could never run because FindOrCreateByFinder's superclass method already handled it. The FindByBooleanFinder/FindAllByBooleanFinder pair duplicated the same pattern-swap override for the same structural reason. Replace the hierarchy with flat classes (SingleResultFinder, ListResultFinder, CountFinder, ListOrderByFinder) that compose a DynamicFinder grammar instance and are configured via static factories, in both grails-datamapping-core and its rx mirror. The construct-from-Equal-expressions logic and the boolean-clause handling now exist in exactly one place each. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Fix a dangling Javadoc cross-reference in SingleResultFinderSpec to a nonexistent "field-ordering note". - Add an explicit 0 * query.projections() assertion in RxListResultFinderSpec so the "no distinct()" quirk documented in RxListResultFinder's class Javadoc is self-verifying rather than incidental. - Add a createFinderInvocation-level test for the And/Or literal-split quirk in DynamicFinderSpec; previously only buildMatchSpec (the compile-time matcher) exercised it, leaving the actual runtime path finders call unverified. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
FinderMethod declares invoke(Class, String, ...) with raw Class/ Closure parameters (suppressed at the interface level), so every override necessarily reintroduces the same raw-type warning at its own call site - IntelliJ flags each override individually, and ListOrderByFinder already suppresses per-method for the same reason. Apply the same @SuppressWarnings("rawtypes") to CountFinder's three invoke overloads, including the DetachedCriteria one, which stays raw to match DynamicFinderInvocation.setDetachedCriteria's existing raw parameter type rather than diverging from it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- operatorPatterns/operators fields are only ever assigned in the constructor - make them final. - Diamond operator for the methodExpressions map initializer. - Merge two identical-body SecurityException/NoSuchMethodException catch branches into multi-catch, in both the static initializer and registerNewMethodExpression. - Suppress the intentionally-ignored Matcher.find() result in createFinderInvocation (isMethodMatch already guarantees the match succeeds before a finder's invoke() is ever called). - buildMatchSpec: the local pattern "(prefix)([A-Z]\w*)" has no alternation, so group 2 is guaranteed non-null whenever find() succeeds - drop the always-true querySequence != null conjunct, and collapse the now childless outer if into the inner one. - Drop two self-reassignments (x = getInitializedExpression(x, args)) now that the helper is confirmed to always mutate-and-return the same reference; and delete a soloArgs array that was populated but never read. - Extract the ~25-line fetch/cache argument-map handling duplicated verbatim between both populateArgumentsForCriteria overloads into a shared applyFetchAndCacheArguments helper, parameterized over the join/cache operations since Query and BuildableCriteria don't share a supertype exposing them. Convert the surviving sort-map branches to pattern variables, dropping an unused `value` local along the way. - configureQueryWithArguments: fold the instanceof check and cast into a single pattern-variable condition. - Drop the redundant Iterable cast on methodExpressions.keySet() and replace criteria.remove(0) with removeFirst(). - Leave targetClass's unused-parameter warning suppressed rather than removing the parameter (call-site compatibility with grails-data-hibernate5/7 and grails-data-mongodb) and leave the Class<? extends Object> wildcard alone (documented GROOVY-9460 workaround already noted in the existing TODO). Verified via the full grails-datamapping-core and grails-datamapping-core-test suites - no behavior change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Checked: GROOVY-9460 (Class<D> rejected against a Class<?> parameter under static compilation) was fixed in Groovy 2.5.16/3.0.6/4.0.0-alpha-1. This project is on Groovy 5.0.x, well past the fix, so the Class<? extends Object> workaround is obsolete - simplify to Class<?>. Verified against every real call site, including the @CompileStatic grails.gorm.DetachedCriteria#list, which passes a Class<T> field (exactly the pattern the bug affected): grails-datamapping-core, grails-datamapping-rx, and grails-data-hibernate5-core all compile clean, and the core test suite is green. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- getInitializedExpression's return value is now unused at both call sites (the last commit dropped the self-reassignments) - change it to void and drop the stale "@return"/removed-IsNull-path Javadoc that no longer matched the commented-out code. - Both populateArgumentsForCriteria overloads wrapped their sort-object instanceof chain in a redundant "if (sortObject != null)" guard - instanceof already returns false for null, so the wrapper is eliminable without changing behavior. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Both the "select"/LAZY-named-mode if-branch and the final fallback returned FetchType.LAZY, so the if condition was a no-op guard around an outcome identical to just falling through - drop it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
javaClass/methodName/arguments/expressions/criteria/operator are only ever set in the constructor and have no setters - make them final. detachedCriteria keeps its mutable setter, so it stays as-is. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
createFinderInvocation's Class/Closure parameters are raw to match FinderMethod's existing raw signature (finder invoke() overloads delegate straight through). Suppress at the interface level, same as FinderMethod itself already does. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- match.find() result is intentionally ignored - isMethodMatch already guarantees the match succeeds before invoke() is ever called, same as DynamicFinder#createFinderInvocation. - new LinkedHashMap((Map) arguments[0]) is an unchecked copy-constructor call on a raw Map, needed since FinderMethod's invoke() signature is itself raw. Both suppressed on the enclosing invoke() method, alongside the existing rawtypes suppression. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Raw Class/Closure/DetachedCriteria on the three invoke overloads, same pattern as CountFinder/SingleResultFinder. - findAllByBoolean(MappingContext) had no caller anywhere - it mirrors the Datastore/MappingContext factory-pair pattern every finder class uses (the MappingContext overload exists for unit testing without a full Datastore, as findAllBy(MappingContext) already is), so add the missing test instead of removing the factory. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Raw Class/Closure/DetachedCriteria on the three invoke overloads. - constructFromEqualExpressions' Map.put on the raw HashMap is "unchecked", a separate category from the "rawtypes" it already suppressed. - findByBoolean/findOrCreateBy/findOrSaveBy(MappingContext) had no callers, same Datastore/MappingContext factory-pair pattern as ListResultFinder - add the missing stateless-mode tests (mirroring findBy(MappingContext)'s existing one) instead of removing them. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Every flagged constructor is genuinely exercised, just never via a literal "new Xxx(...)" expression for these particular classes: DynamicFinder's registry invokes the (Class, String) constructor reflectively via Constructor.newInstance, and MethodExpressionSpec's existing round-trip tests invoke both shapes reflectively via Class.getConstructor(...).newInstance(...) - so IntelliJ's static usage tracker can't see either call site. Suppress rather than add redundant tests, since coverage already exists. Also suppress the base constructor's unused targetClass parameter - the field it feeds is already @deprecated and unused by design, kept only so every subclass can offer the (Class, String) shape uniformly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
convertArguments and convertArgumentsForProp each had their own copy of "fall back to the identity property when getPropertyByName returns null" - extract a shared resolveProperty helper instead. This also lets convertArgumentsForProp drop its now-unused PersistentEntity/ propertyName parameters, and removes NotInList#convertArguments' redundant self-assigned locals along the way. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This pull request refactors the GORM dynamic-finder implementations (sync and Rx) from deep inheritance hierarchies into flat, factory-configured finder classes that compose a shared DynamicFinder/FinderGrammar. This modernizes the design, reduces duplication/drift risk between finder variants, and adds dedicated unit test coverage for the new entry points (including reflective DetachedCriteria overloads used by Groovy dispatch).
Changes:
- Introduces composed finder implementations:
SingleResultFinder/ListResultFinder/CountFinder(core) andRxSingleResultFinder/RxListResultFinder/RxCountFinder(rx). - Updates enhancer/static API wiring (
GormEnhancer,RxGormStaticApi) to register the new factories instead of instantiating the old subclasses. - Adds/updates tests to exercise the real public
invoke(...)seams (includinginvoke(Class, String, DetachedCriteria, Object[])).
Reviewed changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| grails-datamapping-rx/src/main/groovy/org/grails/gorm/rx/finders/RxSingleResultFinder.groovy | New composed Rx “single result” dynamic finder (findBy/findByBoolean/findOrCreateBy/findOrSaveBy). |
| grails-datamapping-rx/src/main/groovy/org/grails/gorm/rx/finders/RxListResultFinder.groovy | New composed Rx “list result” dynamic finder (findAllBy/findAllByBoolean). |
| grails-datamapping-rx/src/main/groovy/org/grails/gorm/rx/finders/RxCountFinder.groovy | New composed Rx countBy finder reusing core CountFinder.applyCriteriaAndCount. |
| grails-datamapping-rx/src/main/groovy/org/grails/gorm/rx/api/RxGormStaticApi.groovy | Rewires Rx dynamic-finder registration to new finder factories. |
| grails-datamapping-rx/src/test/groovy/org/grails/gorm/rx/finders/RxSingleResultFinderSpec.groovy | New spec covering the new Rx single-result finder entry points. |
| grails-datamapping-rx/src/test/groovy/org/grails/gorm/rx/finders/RxListResultFinderSpec.groovy | New spec covering the new Rx list-result finder entry points. |
| grails-datamapping-rx/src/test/groovy/org/grails/gorm/rx/finders/RxCountFinderSpec.groovy | Updates tests for the new Rx countBy finder entry points. |
| grails-datamapping-rx/src/main/groovy/org/grails/gorm/rx/finders/FindByFinder.groovy | Removed legacy inheritance-based Rx finder. |
| grails-datamapping-rx/src/main/groovy/org/grails/gorm/rx/finders/FindByBooleanFinder.groovy | Removed legacy inheritance-based Rx finder. |
| grails-datamapping-rx/src/main/groovy/org/grails/gorm/rx/finders/FindAllByFinder.groovy | Removed legacy inheritance-based Rx finder. |
| grails-datamapping-rx/src/main/groovy/org/grails/gorm/rx/finders/FindAllByBooleanFinder.groovy | Removed legacy inheritance-based Rx finder. |
| grails-datamapping-rx/src/main/groovy/org/grails/gorm/rx/finders/FindOrCreateByFinder.groovy | Removed legacy inheritance-based Rx finder. |
| grails-datamapping-rx/src/main/groovy/org/grails/gorm/rx/finders/FindOrSaveByFinder.groovy | Removed legacy inheritance-based Rx finder. |
| grails-datamapping-rx/src/main/groovy/org/grails/gorm/rx/finders/CountByFinder.groovy | Removed legacy inheritance-based Rx finder. |
| grails-datamapping-rx/src/test/groovy/org/grails/gorm/rx/finders/FindByFinderSpec.groovy | Removed legacy Rx finder spec. |
| grails-datamapping-rx/src/test/groovy/org/grails/gorm/rx/finders/FindByBooleanFinderSpec.groovy | Removed legacy Rx finder spec. |
| grails-datamapping-rx/src/test/groovy/org/grails/gorm/rx/finders/FindAllByFinderSpec.groovy | Removed legacy Rx finder spec. |
| grails-datamapping-rx/src/test/groovy/org/grails/gorm/rx/finders/FindAllByBooleanFinderSpec.groovy | Removed legacy Rx finder spec. |
| grails-datamapping-rx/src/test/groovy/org/grails/gorm/rx/finders/FindOrCreateByFinderSpec.groovy | Removed legacy Rx finder spec. |
| grails-datamapping-rx/src/test/groovy/org/grails/gorm/rx/finders/FindOrSaveByFinderSpec.groovy | Removed legacy Rx finder spec. |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/SingleResultFinder.java | New composed sync “single result” dynamic finder. |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/ListResultFinder.java | New composed sync “list result” dynamic finder. |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/CountFinder.java | New composed sync countBy finder (with reusable helper for Rx). |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/FinderSupport.java | Replaces AbstractFinder with a shared static session-execution helper. |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/FinderGrammar.java | Introduces a composition seam implemented by DynamicFinder. |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/DynamicFinder.java | Refactors DynamicFinder into a composable grammar/utility class (not a base finder). |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/MethodExpression.java | Refactors argument conversion/property resolution and documents reflective constructors. |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/DynamicFinderInvocation.java | Makes invocation fields immutable (final) aside from detached criteria. |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/ListOrderByFinder.java | Refactors listOrderBy finder to implement FinderMethod directly (no base class). |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/GormEnhancer.groovy | Rewires sync dynamic-finder registration to new finder factories. |
| grails-datamapping-core/src/test/groovy/org/grails/datastore/gorm/finders/SingleResultFinderSpec.groovy | New spec for composed sync single-result finder. |
| grails-datamapping-core/src/test/groovy/org/grails/datastore/gorm/finders/ListResultFinderSpec.groovy | New spec for composed sync list-result finder. |
| grails-datamapping-core/src/test/groovy/org/grails/datastore/gorm/finders/CountFinderSpec.groovy | New spec for composed sync countBy finder behavior. |
| grails-datamapping-core/src/test/groovy/org/grails/datastore/gorm/finders/ListOrderByFinderSpec.groovy | New spec for refactored listOrderBy finder. |
| grails-datamapping-core/src/test/groovy/org/grails/datastore/gorm/finders/FinderSupportSpec.groovy | New spec for “stateless mode” guard behavior. |
| grails-datamapping-core/src/test/groovy/org/grails/datastore/gorm/finders/DynamicFinderInvocationSpec.groovy | New spec for invocation value-object behavior. |
| grails-datamapping-core/src/test/groovy/org/grails/datastore/gorm/finders/MethodExpressionSpec.groovy | New spec to comprehensively cover method-expression operators and conversions. |
| grails-datamapping-core/src/test/groovy/org/grails/datastore/gorm/finders/FinderTestEntity.groovy | New shared fixture for finder-package unit tests. |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/FindByFinder.java | Removed legacy inheritance-based sync finder. |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/FindByBooleanFinder.java | Removed legacy inheritance-based sync finder. |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/FindAllByFinder.java | Removed legacy inheritance-based sync finder. |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/FindAllByBooleanFinder.java | Removed legacy inheritance-based sync finder. |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/FindOrCreateByFinder.java | Removed legacy inheritance-based sync finder. |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/FindOrSaveByFinder.java | Removed legacy inheritance-based sync finder. |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/CountByFinder.java | Removed legacy inheritance-based sync finder. |
| grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/finders/AbstractFindByFinder.java | Removed legacy intermediate base class. |
Suppressed comments (4)
grails-datamapping-rx/src/test/groovy/org/grails/gorm/rx/finders/RxSingleResultFinderSpec.groovy:128
- Same issue as the non-detached-criteria case: this test stubs
singleResult()to return an entity instance, but RxGORM expectsRxQuery.singleResult()to return anObservable. Using anObservable.just(...)stub ensures the test matches production behavior.
grails-datamapping-rx/src/test/groovy/org/grails/gorm/rx/finders/RxCountFinderSpec.groovy:75 RxCountFinderultimately callssingleResult()on an Rx query, which is expected to be reactive (RxQuery.singleResult()returns anObservable). Stubbing a rawLonghere doesn’t reflect the real contract and can hide a type mismatch inRxGormStaticApi.methodMissing.
This issue also appears on line 96 of the same file.
grails-datamapping-rx/src/test/groovy/org/grails/gorm/rx/finders/RxCountFinderSpec.groovy:97
- Same return-type issue in this test:
singleResult()should be stubbed as anObservable(perRxQuery.singleResult()), and the assertion should consume the observable, otherwise the test can pass while production code returns anObservable<Number>.
grails-datamapping-rx/src/test/groovy/org/grails/gorm/rx/finders/RxSingleResultFinderSpec.groovy:179 findByBooleanis invoked fromRxGormStaticApi.methodMissing(which returns anObservable), so stubbingsingleResult()with a raw entity here doesn’t match the expected reactive return type (RxQuery.singleResult()). This test should use anObservablestub and assert by consuming it.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
The observation regarding the test stubbing is correct. In RxGORM, reactive query methods return an To address this, the test should be updated to return an |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 8.1.x #16154 +/- ##
===================================================
+ Coverage 32.7869% 59.7096% +26.9227%
- Complexity 563 25442 +24879
===================================================
Files 84 2206 +2122
Lines 4941 108815 +103874
Branches 864 19790 +18926
===================================================
+ Hits 1620 64973 +63353
- Misses 3061 34982 +31921
- Partials 260 8860 +8600
🚀 New features to boost your workflow:
|
…s Observable query.singleResult() returns Observable<T> in production (RxQuery#singleResult), and the plain findBy/findByBoolean/countBy paths pass that value straight through without unwrapping it. Five tests stubbed singleResult() with a raw entity/Long instead, exercising a shape that can never occur in production and silently skipping the unwrap step real callers must do. Flagged by automated PR review on #16154. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ug in RxSingleResultFinder Adds tests for setPattern delegation, the null-detachedCriteria branch of the reflective 4-arg invoke() overload, the ConversionException->MissingMethodException mapping, DynamicFinder's buildMatchSpec/configureQueryWithArguments/ populateArgumentsForCriteria branches, and ListOrderByFinder's Map-argument handling, across the six composed finder classes (sync + rx). Also fixes a genuine latent bug surfaced while closing these gaps: RxSingleResultFinder's findOrCreateBy*/findOrSaveBy* empty-result path ran inside a spawned Thread with no exception handling, so a thrown MissingMethodException (e.g. from a non-Equal expression) killed the thread silently instead of reaching the Observable's error channel - any blocking caller would hang forever. Wrapped the thread body so failures now propagate via Subscriber#onError, and added a test proving the fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Review note (not inline, because the file is outside the diff): |
8.1.x added DatastoreResolver constructors (GORM O(M+N) scaling) and sort argument validation to the finder classes this branch replaces. Carry both over to the composed finders: - SingleResultFinder, ListResultFinder and CountFinder gain a (DatastoreResolver, MappingContext) factory and hold a resolver that FinderSupport resolves on every invocation; the Datastore factories wrap the datastore in a constant resolver. - ListOrderByFinder takes the 8.1.x behaviour: orders by every And-separated property, normalizes the order direction through DynamicFinder.normalizeDirection, and no longer applies a distinct projection. - DynamicFinder keeps the 8.1.x sort property and direction validation for both populateArgumentsForCriteria overloads. - DefaultGormApiFactory registers the composed finders through the resolver factories. - The specs 8.1.x added against the removed classes are ported to the composed finders and the finder specs cover the resolver factories.
- Type AbstractDetachedCriteria.dynamicFinders as List<FinderMethod>, which is what the list holds now that DynamicFinder no longer implements FinderMethod. - Stub RxQuery.singleResult() with an Observable in the remaining RxSingleResultFinderSpec features so every findBy path exercises the reactive return type. - Document the removed finder classes and their factory replacements in the Grails 8 upgrade guide.
|
Fixed in a091ca0: The branch is also merged with current |
… count spec ListResultFinder applied query.projections().distinct() before list(). The old FindAllByFinder stopped doing that in 2926a0f (#16066), so this was a regression reintroduced by the refactor rather than a preserved quirk. GORM for Neo4j only supports count and id projections and threw UnsupportedOperationException for every findAllBy* call, failing 60 tests in the Neo4j functional job. Remove the call, assert in ListResultFinderSpec that no projection is applied, and drop the sync/rx inconsistency notes that described the removed behavior. DisjunctionQuerySpec."Count all dogs or pets with the name Jack" was marked @PendingFeature for #15789. CountFinder now adds OR criteria through Query.add(Junction, Criterion), which resolves an association argument to its identifier the way the AND path always did, so the count is correct and Spock reported the unexpected pass as a failure. Remove the annotation. Fixes #15789
|
Assuming this next round of tests pass, we should merge this PR |
✅ All tests passed ✅🏷️ Commit: 60064c3 Learn more about TestLens at testlens.app/docs. |
|
@jdaugherty Isn't this a breaking change that should not land in a minor release update? |
|
Per discussion, I'll move this into 8.0. |
#16154 replaced it with the legacy "original author or authors" header. The 8.0.x backport kept the ASF header, but the merge cannot carry that over since only 8.1.x changed the file.
Backport of apache#16154 to 8.0.x. The dynamic finders in org.grails.datastore.gorm.finders no longer form an AbstractFinder -> DynamicFinder -> AbstractFindByFinder -> concrete finder chain. SingleResultFinder, ListResultFinder and CountFinder are flat classes, created through static factories, that compose a DynamicFinder. DynamicFinder is now only the method-name grammar and criteria builder. - findOrCreateBy* and findOrSaveBy* share one implementation of building an instance from the Equal expressions. The old FindOrSaveByFinder copy of that branch could never run - countBy*Or* resolves association arguments to their identifiers, as countBy*And* does, which fixes the MongoDB under-count. The @PendingFeature on the Mongo spec is removed - AbstractDetachedCriteria#dynamicFinders is typed List<FinderMethod> - The removed public classes and the factories that replace them are listed in the upgrade guide The RxGORM half of apache#16154 is not included, because grails-datamapping-rx is not built on 8.0.x. ListOrderByFinder keeps, and the new FinderSupport gets, the ASF license header. Fixes apache#15789 Co-authored-by: James Daugherty <jdaugherty@jdresources.net>
Summary
AbstractFinder -> DynamicFinder -> AbstractFindByFinder -> concrete finderinheritance chain inorg.grails.datastore.gorm.finders(grails-datamapping-core) and the parallel hierarchy inorg.grails.gorm.rx.finders(grails-datamapping-rx) with flat classes configured via static factories, composing a sharedDynamicFinder/FinderGrammarinstead of extending it.FindOrSaveByFinder: its own "construct from Equal expressions on null result" branch could never execute because the superclass (FindOrCreateByFinder) already performed construction-and-conditional-save before it. The new design has exactly one implementation of that logic (SingleResultFinder#constructFromEqualExpressions), shared byfindOrCreateBy/findOrSaveBy, so this class of bug can't recur.grails-datamapping-core-test) caught a real regression introduced mid-refactor - a droppedinvoke(Class, String, DetachedCriteria, Object[])overload needed byAbstractDetachedCriteria#methodMissing's dynamic Groovy dispatch - which is fixed and covered by dedicated unit tests on all 6 affected classes (3 core, 3 rx).findOrCreateBy/findOrSaveBymissing the Or/comparison-operator validation the sync side has.findAllBy*no longer applies adistinct()projection. The refactor had reintroduced the call that feat: GORM O(M+N) scaling — GormRegistry, SessionResolver infrastructure, and core-class tests (consolidates #15779, #15780, #15790) #16066 already removed fromFindAllByFinder; GORM for Neo4j only supports count and id projections, so everyfindAllBy*failed there.countBy*Or*now resolves association arguments to their identifiers (the OR path goes throughQuery.add(Junction, Criterion)like the AND path), which fixes the MongoDB under-count tracked in MongoDB: count over an OR disjunction (countBy*Or*) under-counts #15789; the@PendingFeatureon the Mongo spec is removed.Test plan
:grails-datamapping-core:test- full suite green:grails-datamapping-rx:test- full suite green:grails-datamapping-core-test:test(TCK-backed, exercises real GORM dynamic-finder dispatch end-to-end) - full suite green:grails-datamapping-core:codeStyle/:grails-datamapping-rx:codeStyle- cleanPublic API changes
This refactor removes public classes from
org.grails.datastore.gorm.finders(AbstractFinder,AbstractFindByFinder,FindByFinder,FindByBooleanFinder,FindAllByFinder,FindAllByBooleanFinder,FindOrCreateByFinder,FindOrSaveByFinder,CountByFinder) and theirorg.grails.gorm.rx.finderscounterparts.DynamicFinderis now a concrete grammar class: it no longer implementsFinderMethod, has a different constructor, and noinvoke/doInvokeInternal. Applications are unaffected; a third-party GORM datastore or plugin that extends or instantiates any of the removed classes must switch to theSingleResultFinder/ListResultFinder/CountFinderfactory methods, which accept aDatastore, aDatastoreResolverplusMappingContext(the formDefaultGormApiFactoryregisters), or a bareMappingContext. This is documented in the Grails 8 upgrade guide (upgrading80x.adoc, section 21).AbstractDetachedCriteria#dynamicFindersis now typedList<FinderMethod>, matching what the list holds.Merge with 8.1.x
Merged the current
8.1.xbranch, which added theDatastoreResolverconstructors (GORM O(M+N) scaling) and sort/order argument validation to the old finder hierarchy. Both are carried over: every composed finder factory has a(DatastoreResolver, MappingContext)form and resolves the datastore on each invocation,ListOrderByFinderorders by everyAnd-separated property and rejects an invalidorderdirection, and the sort validation inDynamicFinderis preserved. The specs 8.1.x added against the old classes are ported to the composed finders.🤖 Generated with Claude Code