test: add @Query Data Service connection routing tests#15423
Merged
jdaugherty merged 2 commits into7.0.xfrom Feb 21, 2026
Merged
test: add @Query Data Service connection routing tests#15423jdaugherty merged 2 commits into7.0.xfrom
jdaugherty merged 2 commits into7.0.xfrom
Conversation
Add unit and functional tests verifying that @Query-annotated Data Service methods (find-one, find-all, update) correctly route to non-default datasources when @transactional(connection) is specified. Tests cover both abstract class and interface service patterns using FindOneStringQueryImplementer, FindAllStringQueryImplementer, and UpdateStringQueryImplementer - previously untested code paths. Assisted-by: Claude Code <Claude@Claude.ai>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive test coverage for @Query-annotated Data Service methods with multi-datasource connection routing via @Transactional(connection). The changes validate that FindOneStringQueryImplementer, FindAllStringQueryImplementer, and UpdateStringQueryImplementer correctly route HQL queries to non-default datasources—code paths that were previously untested following the connection routing fixes in PRs #15395 and #15416.
Changes:
- Unit tests: 7 new tests in
grails-data-hibernate5covering@Queryfind-one, find-all, and update operations for both abstract class and interface service patterns - Functional tests: 4 new integration tests in
grails-test-examplesvalidating the same operations in a full Grails application context - Service methods: Added
findOneByQuery,findAllByQuery, andupdateAmountByNameto bothProductServiceabstract class andProductDataServiceinterface
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
grails-test-examples/.../DataServiceMultiDataSourceSpec.groovy |
Added 4 integration tests validating @Query methods route to secondary datasource (find-one, find-one null, find-all, update) |
grails-test-examples/.../ProductService.groovy |
Added 3 @Query-annotated abstract methods for testing HQL query routing |
grails-data-hibernate5/.../DataServiceMultiDataSourceSpec.groovy |
Added 7 unit tests covering @Query routing for both abstract and interface service patterns |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jdaugherty
approved these changes
Feb 21, 2026
...e/src/test/groovy/org/grails/orm/hibernate/connections/DataServiceMultiDataSourceSpec.groovy
Show resolved
Hide resolved
...datasource/src/integration-test/groovy/functionaltests/DataServiceMultiDataSourceSpec.groovy
Show resolved
Hide resolved
Restore Javadoc comments on ProductService, ProductDataService, and DataServiceMultiDataSourceSpec that were inadvertently removed. Assisted-by: Claude Code <Claude@Claude.ai>
jdaugherty
approved these changes
Feb 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@Query-annotated Data Service methods routing to non-default datasources via@Transactional(connection)FindOneStringQueryImplementer,FindAllStringQueryImplementer, andUpdateStringQueryImplementer- previously untested code pathsChanges
DataServiceMultiDataSourceSpecingrails-data-hibernate5-core): 7 new tests covering@Queryfind-one, find-all, and update for both abstract and interface servicesDataServiceMultiDataSourceSpecingrails-test-examples): 4 new integration tests covering@Queryfind-one, find-all, and update in a full Grails application contextTest Results
codeStyle: passContext
During the exhaustive bug pattern sweep for connection routing issues (#15395, #15416), we identified that
findStaticApiForConnectionId(domainClassNode, newMethodNode)in the 3 String Query implementers had no test coverage for multi-datasource routing. Investigation confirmed the pattern works correctly via the declaring-class fallback inTransactionalTransform.findTransactionalAnnotation(), but the code paths lacked regression tests.