Hibernate 7 - Step 2#15568
Conversation
…and proper applicationClass - Replace executeQuery(plainString) and executeUpdate(plainString) calls with the (String, Map) overloads (empty map for parameterless queries). HibernateGormStaticApi intentionally rejects plain String in the no-arg overload to prevent HQL injection; parameterless static queries must use the Map overload. - Add applicationClass = Application to @Integration so the spec shares the same application context and transaction manager as the other specs in this module, preventing test-data bleed between specs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts: # NOTICE # dependencies.gradle # gradle/publish-root-config.gradle
…ibernate7 # Conflicts: # .idea/codeStyles/Project.xml # NOTICE # build-logic/plugins/build.gradle # dependencies.gradle # gradle/publish-root-config.gradle
Following the pattern used in Hibernate 5, I have moved the vendored Spring Framework ORM Hibernate 7 integration classes from the core module to a dedicated spring-orm module:
- Created Module: grails-data-hibernate7-spring-orm (located in grails-data-hibernate7/spring-orm).
- Moved Classes: All classes in org.grails.orm.hibernate.support.hibernate7 (including HibernateTransactionManager, HibernateTemplate, LocalSessionFactoryBean, etc.) are now in the new module.
- Updated Dependencies:
- Added the new module to settings.gradle.
- Updated grails-data-hibernate7-core, grails-plugin, boot-plugin, and dbmigration to depend on the new spring-orm module.
- Updated gradle/publish-root-config.gradle to ensure the new module is included in the publishing process.
- HibernateDetachedCriteria.isNumericPropertyType: box primitive types before the Number.isAssignableFrom check so that domains declaring numeric properties as primitives (int/long/double/float/short/byte) work correctly in where-DSL arithmetic expressions. Method is protected to allow subclass overrides. - ToManyEntityMultiTenantFilterBinder.bind: add null guard for getHibernateAssociatedEntity() return value to prevent NullPointerException on partially-resolved associations. - grails-data-hibernate7/README.md: add grails-data-hibernate7-spring-orm to the Module Structure table. - Tests: new HibernateDetachedCriteriaSpec covering boxed and all 6 primitive numeric types, non-numeric delegation, and unknown property. Added null-associated-entity test to ToManyEntityMultiTenantFilterBinderSpec. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts: # grails-data-mongodb/core/src/test/groovy/org/apache/grails/data/mongo/core/GrailsDataMongoTckManager.groovy # grails-data-mongodb/core/src/test/groovy/org/grails/datastore/gorm/mongo/BeforeUpdatePropertyPersistenceSpec.groovy # grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/CustomAutoTimestampSpec.groovy # grails-datamapping-core-test/src/test/groovy/org/grails/datastore/gorm/NestedCriteriaWithNamedQuerySpec.groovy # grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/GormStaticApi.groovy # grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/query/NamedCriteriaProxy.groovy # grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/NamedQuerySpec.groovy # grails-test-suite-uber/src/test/groovy/grails/compiler/DomainClassWithInnerClassUsingStaticCompilationSpec.groovy
This comment has been minimized.
This comment has been minimized.
…s any hibernate 5 or hibernate 7 project
This comment has been minimized.
This comment has been minimized.
# Conflicts: # grails-data-mongodb/core/src/test/groovy/org/apache/grails/data/mongo/core/GrailsDataMongoTckManager.groovy
This comment has been minimized.
This comment has been minimized.
…correct versions are chosen.
|
To help guide the review of this PR, I want to provide a high-level overview of the major architectural changes and design decisions introduced in this branch. Given the magnitude of the changes, this
These architectural shifts are the primary drivers of the footprint of this PR. The accompanying style adjustments (CodeNarc, Checkstyle, PMD) were applied mechanically to ensure the new monorepo Let me know if you have any questions about specific implementation details in these areas!*** |
…le-quotes inside single-quoted strings
Three regex bugs in registerCodenarcFixTask:
1. SpaceAroundMapEntryColon matched the first ':' of '::' method references,
turning String::trim into String: :trim.
Fix: add (?!:) lookahead so only standalone map-entry colons are matched.
2. UnnecessaryGString fused the closing quote of a GString with the opening
quote of an adjacent plain string (e.g. obj."${name}"("arg") became
obj."${name}'('arg")).
Fix: add (?<!}) lookbehind so a double-quote preceded by '}' is never
treated as an opening delimiter.
3. UnnecessaryGString matched double-quoted content inside single-quoted strings
(e.g. 'format "hh:mm:ss"'), corrupting the outer string.
Fix: the regex alternation now first matches and skips complete single-quoted
strings so their embedded double-quoted content is never converted.
Tests added for all three cases.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Assisted-by: opencode:openai/gpt-5.5 oracle
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 8.0.x #15568 +/- ##
===================================================
- Coverage 48.4322% 19.0184% -29.4138%
+ Complexity 15265 288 -14977
===================================================
Files 1875 57 -1818
Lines 85852 3423 -82429
Branches 14972 597 -14375
===================================================
- Hits 41580 651 -40929
+ Misses 37863 2642 -35221
+ Partials 6409 130 -6279 🚀 New features to boost your workflow:
|
Resolved dependencies.gradle by taking the latest base dependency versions for Spring Boot, Spock, and Sitemesh while retaining Hibernate 7 BOM-specific dependency sections. Assisted-by: opencode:openai/gpt-5.5 oracle
a8e9fc9 to
8452458
Compare
|
I found a list of items here that I think are important and will have a PR against this PR in a few hours. |
Resolve dependencies.gradle conflict: take mongodb 5.8.0 from 8.0.x (aligned with the Spring Boot 4.1 BOM) and keep the reactor.version 3.8.5 entry added on this branch. Assisted-by: claude-code:claude-opus-4-8
@jamesfredley Ok, I started reviewing, but I'll hold off until you are done. |
|
@matrei @jdaugherty @borinquenkid #15731 is the list of items I found. Feel free to commit to that branch and anything can be added or subtracted. The PR description will be update in a few minutes with a full breaking changes table between h5.6 and h7.2. Hopefully CI will finish in that PR, if not feel free to push fixes. |
|
@jamesfredley I have said it before but I am highly against module substitution to expand test coverage. For multiple reasons:
We should just copy tests to expand coverage. |
|
Thinking ahead to the broader roadmap: we also need to start actively planning and working toward Hibernate 8. With that in mind, framing Grails 8.0 as a permanent, dual-baseline bridge isn't sustainable. It forces us to carry too much legacy weight while trying to leapfrog forward. Instead, we should use this PR to clean house and establish a clear, fast-moving release strategy: The Proposed Lifecycle Compromise
Why This Splitting of the Difference Works
By establishing this hard cutoff, we protect developer ergonomics, clean up the CI pipeline, and immediately clear the runway to start targeting Hibernate 8 features. |
|
@borinquenkid until there is wider adoption or a dependency change that forces the retirement of 5.x, I do not see a need to preemptively retire the other code line. We should first release dual code lines and evaluate after. |
I think I did not make myself clear: G8 supports 5 and 7, minor patches to 5 no new features. Release quicly a G8.1 with new features and drop H5.. 5 is just our thing for this release. That way we can do things @jamesfredley way just to get it out the door and then cut off immediately and do things your way. Moving forward we should be able to just have one hibernate module once spring 5 comes in the horizon we will have a branch for H8 or whatever is relevant at the time. |
|
Our release policy forbids dropping support for a feature in a minor release |
Fair enough. So that would mean dropping H5 for Grails 9, SpringBoot 4.1 |
Merge changed package back to `grails.gorm.tests`. Align package and imports accordingly.
Merge changed package back to `grails.gorm.tests`. Align package and imports accordingly.
After a merge, `Hibernate7OptimisticLockingSpec` had two `setupSpec()` methods.
🚨 TestLens detected 1 failed test 🚨Here is what you can do:
Test Summary
🏷️ Commit: 2b11a80 Test FailuresUserControllerSpec > User list (:grails-test-examples-scaffolding:integrationTest in CI / Functional Tests (Java 21, indy=false))Muted TestsSelect tests to mute in this pull request:
Reuse successful test results:
Click the checkbox to trigger a rerun:
Learn more about TestLens at testlens.app. |
Reopening. This PR replaces #15530
Please note that I split off a prerequisite PR #15654
This allows us to better see what changed between hibernate 5 & 7 - otherwise the hibernate 7 code looks like it was just added instead of changed. Commit a47d8cb is the original commit prior to this split if we need to compare this branch to that for any reason (mistakes, etc).