This is an automated email from the ASF dual-hosted git repository. borinquenkid pushed a commit to branch 8.0.x-hibernate7 in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 2b26edfdd7d9cea00da30cf2dc7a3e9f8c84f6e1 Author: Walter B Duque de Estrada <[email protected]> AuthorDate: Sun Jan 18 11:24:25 2026 -0600 update progress --- .../core/HIBERNATE7-UPGRADE-PROGRESS.md | 40 ++++++++++++++++++++++ .../cfg/domainbinding/BasicValueIdCreator.java | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/grails-data-hibernate7/core/HIBERNATE7-UPGRADE-PROGRESS.md b/grails-data-hibernate7/core/HIBERNATE7-UPGRADE-PROGRESS.md index 58dbca7db1..3ea6688c16 100644 --- a/grails-data-hibernate7/core/HIBERNATE7-UPGRADE-PROGRESS.md +++ b/grails-data-hibernate7/core/HIBERNATE7-UPGRADE-PROGRESS.md @@ -5,6 +5,8 @@ This document summarizes the approaches taken, challenges encountered, and futur + + ## Challenges & Failures ### 1. Proxy Initialization Behavior @@ -24,6 +26,44 @@ Each new binder should follow this structure: 3. **Protected Constructor for Testing:** A second constructor that accepts all dependencies as arguments. This allows unit tests to inject mocks for all collaborating classes. 4. **Core Method:** A public method that contains the logic previously held in `GrailsDomainBinder` (e.g., `bindCollectionSecondPass`). +### Refactored Binders +- [x] `BasicValueIdCreator`: Handles the creation of `BasicValue` for identifiers. It uses Hibernate 7's `setCustomIdGeneratorCreator` to map GORM generator names to modern `Generator` implementations. + +#### Implementation +```java + private void initializeGeneratorFactories() { + generatorFactories.put("identity", (context, mappedId) -> new GrailsIdentityGenerator(context, mappedId)); + + BiFunction<GeneratorCreationContext, Identity, Generator> sequenceFactory = (context, mappedId) -> new GrailsSequenceStyleGenerator(context, mappedId); + generatorFactories.put("sequence", sequenceFactory); + generatorFactories.put("sequence-identity", sequenceFactory); + + generatorFactories.put("increment", (context, mappedId) -> new IncrementGenerator()); + generatorFactories.put("uuid", (context, mappedId) -> new UuidGenerator(context.getType().getReturnedClass())); + generatorFactories.put("uuid2", (context, mappedId) -> new UuidGenerator(context.getType().getReturnedClass())); + generatorFactories.put("assigned", (context, mappedId) -> new Assigned()); + generatorFactories.put("table", (context, mappedId) -> new TableGenerator()); + generatorFactories.put("enhanced-table", (context, mappedId) -> new TableGenerator()); + generatorFactories.put("hilo", (context, mappedId) -> new SequenceStyleGenerator()); + } +``` + +#### Test Status (`SequenceGeneratorsSpec`) +| Generator | Status | Error (if FAILED) | +| :--- | :--- | :--- | +| `identity` | [x] PASS | | +| `native` | [x] PASS | | +| `uuid` | [x] PASS | | +| `assigned` | [x] PASS | | +| `sequence` | [ ] FAIL | `AssertionFailure: SequenceStructure not properly initialized` | +| `table` | [ ] FAIL | `NPE: this.optimizer is null` | +| `increment` | [ ] FAIL | `NPE: this.previousValueHolder is null` | + +- [x] `SimpleIdBinder`: Orchestrates the binding of simple identifiers by coordinating `BasicValueIdCreator`, `SimpleValueBinder`, and `PropertyBinder`. +- [x] `PropertyBinder`: Binds `PersistentProperty` to Hibernate `Property`, handling cascade behaviors, access strategies (including Groovy traits), and lazy loading configurations. +- [x] `ManyToOneBinder`: Specialized binder for many-to-one associations, handling composite identifiers and circularity. +- [x] `SimpleValueBinder`: Handles the binding of simple values (columns, types, etc.) to Hibernate `SimpleValue`. + ### Testing Strategy Unit tests should be created for each new binder class (e.g., `CollectionBinderSpec`). These tests should: - Use the protected constructor to inject mocks. diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/BasicValueIdCreator.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/BasicValueIdCreator.java index 9a8516f9eb..9600936a0e 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/BasicValueIdCreator.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/BasicValueIdCreator.java @@ -68,4 +68,4 @@ public class BasicValueIdCreator { .filter(gen -> !("native".equals(gen) && useSequence)) .orElse(useSequence ? "sequence-identity" : "native"); } -} +} \ No newline at end of file
