jdaugherty opened a new pull request, #16485:
URL: https://github.com/apache/grails-core/pull/16485

   ## Why this is needed
   
   Grails 8's `GormInstanceApi.ident()` reads the literal `id` property instead 
of the mapped identifier following the registry consolidation in #16066. That 
loses two behaviors supported in Grails 7:
   
   - With `id name: 'code'`, `ident()` returns `null` instead of the assigned 
`code`.
   - With a composite key, `ident()` returns `null` instead of a serializable 
identifier containing the mapped key fields.
   
   This surfaced during an application upgrade on a Spring Batch parameter 
entity whose key combines a parameter name and its job-execution association. 
Even after persistence, `entity.ident()` was null, so 
`DomainClass.load(entity.ident())` returned null before a proxy could be 
created. It also breaks callers using `get(entity.ident())` to reload such 
entities.
   
   The new public-API regression tests reproduce both problems on Hibernate 5 
and Hibernate 7: before the fix, three of the four tests failed on each version.
   
   ## Changes
   
   - Resolve the identifier through the entity's mapping metadata.
   - Read the mapped property for a single-property identifier, including a 
renamed one.
   - Construct a separate serializable domain instance for composite 
identifiers and copy only the mapped key properties, including associations.
   - Cover generated IDs, renamed IDs, composite-key copying, persisted 
reloads, and lazy loading through public GORM APIs on both Hibernate versions.
   - Exercise the existing default-ID test through the domain API and expand 
the `ident()` reference documentation.
   
   ## Verification
   
   The new regression tests pass on both Hibernate versions after the fix. Full 
affected-module results:
   
   | Module | Passed | Skipped | Failed |
   | --- | ---: | ---: | ---: |
   | `grails-datamapping-core` | 1,694 | 1 | 0 |
   | `grails-data-hibernate5-core` | 950 | 40 | 0 |
   | `grails-data-hibernate7-core` | 3,341 | 30 | 0 |
   
   Main-source style checks and repository-conventions validation also passed. 
Test-source style checks are disabled by the repository's default configuration.
   
   The required repository-wide pre-commit gate also passed:
   
   ```sh
   GRAILS_INCLUDE_MAVEN_LOCAL=1 ./gradlew clean aggregateViolations 
:grails-test-report:check --continue --console=plain --max-workers=4 
-PmaxTestParallel=2
   ```
   
   - Combined report: **22,816 tests, 0 failures, 0 errors, 445 skipped**.
   - Unit report: 19,005 tests, 0 failures/errors, 337 skipped.
   - Integration report: 3,811 tests, 0 failures/errors, 108 skipped.
   - RAT, Checkstyle, CodeNarc, repository conventions, and PMD for its enabled 
modules passed. SpotBugs is disabled in this configuration.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to