feat: GORM O(M+N) scaling — Hibernate 7 adapter wiring and child data…#15774
Closed
borinquenkid wants to merge 1 commit into
Closed
feat: GORM O(M+N) scaling — Hibernate 7 adapter wiring and child data…#15774borinquenkid wants to merge 1 commit into
borinquenkid wants to merge 1 commit into
Conversation
…store init Wires Hibernate 7 to the new GormRegistry with correct child datastore initialization order, fixing the gaps that PR #15771 intentionally deferred: - HibernateDatastore (H7): registers child datastores with GormRegistry eagerly during initialization, preserving schema/database/datasource routing - HibernateGormInstanceApi: use getHibernateTemplate() lazy getter for isAttached(), lock(), and attach() — factory constructor leaves the field null - HibernateGormStaticApi: executeQuery(query, Map) passes params as both named params and query settings so max/offset pagination is applied - HibernateSession: coerceId() converts String IDs to the entity's declared identifier type in retrieveAll(), fixing String→Long lookup mismatch - HibernateGormEnhancerSpec: updated to use GormRegistry public API - HibernateDirtyCheckingSpec / HibernateUpdateFromListenerSpec: local Person renamed to DirtyCheckPerson to avoid DuplicateMappingException with TCK - grails-test-examples/hibernate7: demo33 UniqueConstraintOnHasOneSpec @NotYetImplemented removed (test now passes); GormAdvancedSpec pagination fixed - grails-data-hibernate7-core GormApiAllocationSpec: verifies O(M+N) API count across single-datasource, multi-datasource, and multi-tenant configurations Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR advances the Hibernate 7 (GORM) O(M+N) scaling work by wiring Hibernate 7 into the shared GormRegistry, tightening multi-tenant / multi-datasource session handling, and adjusting query + pagination behavior to better match expected contracts across core, plugin, and TCK/test examples.
Changes:
- Integrate Hibernate 7 datastores and GORM APIs with
GormRegistry(including child datastore qualifier registration and updated API lookups in tests/examples). - Refine Hibernate 7 session/query behavior (ID coercion in bulk retrieval, HQL query wrappers/events, pagination result type updates).
- Expand and update Hibernate 7 test coverage (scalability assertions, transaction/session lifecycle, multi-tenant and multi-datasource behavior).
Reviewed changes
Copilot reviewed 75 out of 75 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| grails-test-examples/hibernate7/grails-multitenant-multi-datasource/grails-app/services/example/MetricService.groovy | Switch static API lookup to GormRegistry |
| grails-test-examples/hibernate7/grails-database-per-tenant/src/integration-test/groovy/example/DatabasePerTenantIntegrationSpec.groovy | Remove console printing; keep logging |
| grails-test-examples/hibernate7/grails-database-per-tenant/grails-app/services/example/AnotherBookService.groovy | Annotation order + flush on save |
| grails-test-examples/hibernate7/grails-database-per-tenant/grails-app/conf/logback.xml | Increase logging verbosity for debugging |
| grails-test-examples/hibernate7/demo33/src/test/groovy/demo/UniqueConstraintOnHasOneSpec.groovy | Remove @NotYetImplemented to enable test |
| grails-data-hibernate7/spring-orm/src/main/java/org/grails/orm/hibernate/support/hibernate7/HibernateTransactionManager.java | Tx detection/logging + exception conversion changes |
| grails-data-hibernate7/ISSUES.md | Add Hibernate 7 scaling/perf notes |
| grails-data-hibernate7/grails-plugin/src/test/groovy/org/grails/plugin/hibernate/support/HibernatePersistenceContextInterceptorSpec.groovy | Bind/unbind native session in test |
| grails-data-hibernate7/grails-plugin/src/main/groovy/org/grails/plugin/hibernate/support/GrailsOpenSessionInViewInterceptor.java | Use sessionFactory-aware OSIV readonly checks |
| grails-data-hibernate7/docs/build.gradle | Pin jline dependency version |
| grails-data-hibernate7/core/src/test/resources/simplelogger.properties | Add targeted test logger category |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/support/hibernate7/HibernateTransactionManagerSpec.groovy | New unit coverage for tx manager behavior |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/support/ClosureEventListenerSpec.groovy | Update listener construction signature |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/SchemaTenantGormEnhancerSpec.groovy | Remove unused import |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/query/HqlQueryContextSpec.groovy | Update expected default HQL aliasing |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateTenantContextProfilingSpec.groovy | New profiling comparison for tenant wrapping |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateSessionSpec.groovy | Add tests for native session fallback contract |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormValidationApiSpec.groovy | Validate API retrieval via GormRegistry |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormStaticApiSpec.groovy | Static API via GormRegistry + paged list type update |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormInstanceApiSpec.groovy | Instance API via GormRegistry |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormEnhancerSpec.groovy | Enhancer tests updated to registry lookups |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateGormApiFactorySpec.groovy | New unit test for API factory outputs |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/HibernateDatastoreIntegrationSpec.groovy | Ensure leaked resources unbound in setup |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/GormRegistryScalabilitySpec.groovy | New O(M+N) registry scalability assertions |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/connections/WhereQueryMultiDataSourceSpec.groovy | Adjust config key format for secondary DS |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/connections/SingleTenantSpec.groovy | Reset registries/resources to prevent leaks/flakes |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/connections/SchemaMultiTenantSpec.groovy | Reset registries/resources + H2 DB close delay |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/connections/MultipleDataSourcesWithEventsSpec.groovy | Use connection-qualified GORM access in tx block |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/connections/DataServiceMultiDataSourceSpec.groovy | Replace interpolated HQL with named params |
| grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/ChildHibernateDatastoreUnitSpec.groovy | Add SCHEMA child session contract tests |
| grails-data-hibernate7/core/src/test/groovy/org/grails/datastore/gorm/GormEnhancerCleanupSpec.groovy | Update cleanup assertions to GormRegistry |
| grails-data-hibernate7/core/src/test/groovy/org/apache/grails/data/testing/tck/tests/PagedResultSpecHibernate.groovy | Update expected paged list class name |
| grails-data-hibernate7/core/src/test/groovy/org/apache/grails/data/hibernate7/core/GrailsDataHibernate7TckManager.groovy | Re-register enhancers after registry cleanup; improve teardown |
| grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/WithNewSessionAndExistingTransactionSpec.groovy | Stabilize connection-pool active-count assertions |
| grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/validation/UniqueWithinGroupSpec.groovy | Avoid duplicate insert; validate after clear |
| grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/services/DataServiceSpec.groovy | Replace interpolated HQL with named params |
| grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/PagedResultListSpec.groovy | Update paged list type assertions |
| grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/hibernatequery/HibernateQuerySpec.groovy | Add coverage for conjunction/disjunction criteria behavior |
| grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/HibernatePagedResultListSpec.groovy | Rename/update paged list tests for new type |
| grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/HibernateGormDatastoreSpec.groovy | Expose typed transaction manager accessor |
| grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/dirtychecking/HibernateUpdateFromListenerSpec.groovy | Rename entity fixture to avoid mapping collisions |
| grails-data-hibernate7/core/src/test/groovy/grails/gorm/tests/dirtychecking/HibernateDirtyCheckingSpec.groovy | Rename entity fixture to avoid mapping collisions |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/TenantBoundHibernateTemplate.groovy | New template to bind tenant during execution |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/support/HibernateRuntimeUtils.groovy | Add insert-active thread-local marker + helpers |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/support/GormAutoTimestampFlushEntityEventListener.java | New flush listener to timestamp before dirty-check |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/support/ClosureEventTriggeringInterceptor.java | Improve state sync + simplify dirty tracking activation |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/support/ClosureEventListener.java | Add deep-validation suppression + registry validation API lookup |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/SchemaTenantGormEnhancer.java | Ensure parent/child datastore init order and qualifier wiring |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/SelectHqlQuery.java | Add paging wrapper + pre/post query events + count projection handling |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/PagedResultList.java | New Hibernate 7 paged list implementation |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/JpaCriteriaQueryCreator.java | Reuse predicate generator to reduce churn |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HqlQueryContext.java | Build default HQL via list-query builder |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HqlListQueryBuilder.java | Improve sort/order clause generation |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQuery.java | Paging wrapper + conjunction/disjunction fixes + native session usage |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateHqlQuery.java | New wrapper query with pre/post query events |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/multitenancy/MultiTenantEventListener.java | Replace enhancer lookups with registry resolver |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateSessionResolver.groovy | New resolver bridging GORM + native session bindings |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateSession.java | Native session handling + bulk retrieval + query creation updates |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormValidationApi.groovy | Add qualifier-aware API creation + lazy template access |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormInstanceApi.groovy | Lazy template getter + deep-validate suppression + behavior alignment |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormEnhancer.groovy | Register Hibernate API factory with GormRegistry |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormApiFactory.groovy | New factory producing Hibernate-specific APIs |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateDatastore.java | Child qualifier registration + session resolution + listener wiring |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/GrailsHibernateTransactionManager.groovy | Bind datastore resource + preferred datastore during tx |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/GrailsHibernateTemplate.java | Improve executeWithNewSession resource unbinding/restore |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/event/listener/HibernateEventListener.java | Construct ClosureEventListener with datastore reference |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/dirty/GrailsEntityDirtinessStrategy.groovy | Use GormRegistry resolver + updated dirty-check logic |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/ChildHibernateDatastore.java | Improve init, tx manager resolution, and native session binding |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/HibernateMappingContextConfiguration.java | Filter entities per-connection + broaden entity annotation detection |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/HibernateMappingContext.java | Return concrete mapping factory + filter per datasource |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernateUtil.java | Guard + handle Hibernate 7 contains() behavior |
| grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/GrailsDomainBinder.java | Minor lambda style change in binding loop |
| grails-data-hibernate7/core/src/main/groovy/grails/orm/CriteriaMethodInvoker.java | Use new PagedResultList type |
| grails-data-hibernate7/core/src/main/groovy/grails/gorm/hibernate/HibernateEntity.groovy | Route static API lookups via GormRegistry; add native SQL helpers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+34
to
39
| <logger name="org.grails.orm.hibernate" level="debug" /> | ||
| <logger name="grails.gorm.transactions" level="debug" /> | ||
| <logger name="org.springframework.transaction" level="debug" /> | ||
|
|
||
| <root level="debug"> | ||
| <appender-ref ref="STDOUT" /> |
Comment on lines
+119
to
+123
| public void disconnect() { | ||
| connected = false; | ||
| if (nativeSession != null && nativeSession.isOpen()) { | ||
| nativeSession.close(); | ||
| } |
Comment on lines
+468
to
+471
| // Determine the unique set of keys for the HQL IN query | ||
| Collection<Object> uniqueKeys = new LinkedHashMap<Object, Object>() {{ | ||
| for (Object k : inputKeys) { put(k, k); } | ||
| }}.keySet(); |
Comment on lines
+443
to
+452
| private static Object coerceId(Object key, Class<?> idType) { | ||
| if (key == null || idType == null || idType.isInstance(key)) { | ||
| return key; | ||
| } | ||
| if (key instanceof String s) { | ||
| if (idType == Long.class) return Long.parseLong(s); | ||
| if (idType == Integer.class) return Integer.parseInt(s); | ||
| } | ||
| return key; | ||
| } |
✅ All tests passed ✅🏷️ Commit: 14e6ca2 Learn more about TestLens at testlens.app. |
Member
Author
|
Superseded by the restructured feat/gorm-registry-h7 branch on top of the new per-adapter PR stack. |
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.
…store init
Wires Hibernate 7 to the new GormRegistry with correct child datastore initialization order, fixing the gaps that PR #15771 intentionally deferred:
Description
Contributor Checklist
Please review the following checklist before submitting your pull request. Pull requests that do not meet these requirements may be closed without review.
Issue and Scope
7.0.x): Bug fixes only. No new features or API changes.7.1.x): New features are welcome, but breaking existing APIs must be avoided.8.0.x): Reserved for major changes. Breaking API changes are permitted.Code Quality
./gradlew build --rerun-tasks../gradlew codeStyleand resolved any violations. See Code Style for details.Licensing and Attribution
Documentation