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 87309e4dea2fd40bc028f9a701ec753cc99903bc
Author: Walter B Duque de Estrada <[email protected]>
AuthorDate: Sat Jan 10 17:32:35 2026 -0600

    more fixes
---
 grails-data-hibernate7/core/HIBERNATE7-TESTS.csv   |  2 --
 .../cfg/domainbinding/SimpleValueBinder.java       | 29 ++++++++++++++++++++++
 .../ColumnConfigToColumnBinderSpec.groovy          |  2 +-
 .../cfg/domainbinding/SimpleValueBinderSpec.groovy |  8 +++---
 4 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/grails-data-hibernate7/core/HIBERNATE7-TESTS.csv 
b/grails-data-hibernate7/core/HIBERNATE7-TESTS.csv
index a7f75a0304..fdf1a88707 100644
--- a/grails-data-hibernate7/core/HIBERNATE7-TESTS.csv
+++ b/grails-data-hibernate7/core/HIBERNATE7-TESTS.csv
@@ -1,6 +1,4 @@
  Test File , Status , Notes 
- 
`src/test/groovy/org/grails/orm/hibernate/HibernateGormInstanceApiSpec.groovy` 
, FAILED , delete() method missing/renamed? remove() called instead.
- 
`src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinderSpec.groovy`
 , FAILED , Generator binding issues. 
  
`src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CascadeBehaviorPersisterSpec.groovy`
 , FAILED , Unsupported cascade style: save-update.
  
`src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CascadeBehaviorFetcherSpec.groovy`
 , FAILED , Expected save-update but got all.
  
`src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnBinderSpec.groovy`
 , FAILED ," Column name mismatch: got ""test"" instead of expected. "
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinder.java
index 133f7d7151..764ba7725a 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinder.java
@@ -5,6 +5,7 @@ import java.util.Optional;
 import java.util.Properties;
 
 import org.hibernate.id.enhanced.SequenceStyleGenerator;
+import org.hibernate.mapping.BasicValue;
 import org.hibernate.mapping.Column;
 import org.hibernate.mapping.Formula;
 import org.hibernate.mapping.SimpleValue;
@@ -76,6 +77,34 @@ public class SimpleValueBinder {
             simpleValue.setTypeName(typeName);
             simpleValue.setTypeParameters(propertyConfig.getTypeParams());
         }
+
+        String generator = propertyConfig.getGenerator();
+        if (generator != null && simpleValue instanceof BasicValue) {
+            BasicValue basicValue = (BasicValue) simpleValue;
+            Properties params = propertyConfig.getTypeParams();
+            final Properties generatorProps = new Properties();
+            if (params != null) {
+                generatorProps.putAll(params);
+            }
+
+            if (SEQUENCE_KEY.equals(generator) && 
generatorProps.containsKey(SEQUENCE_KEY)) {
+                generatorProps.put(SequenceStyleGenerator.SEQUENCE_PARAM, 
generatorProps.getProperty(SEQUENCE_KEY));
+            }
+
+            switch (generator) {
+                case "identity" -> 
basicValue.setCustomIdGeneratorCreator(context -> {
+                    var gen = new org.hibernate.id.IdentityGenerator();
+                    
context.getProperty().getValue().getColumns().get(0).setIdentity(true);
+                    return gen;
+                });
+                case "sequence", "sequence-identity" -> 
basicValue.setCustomIdGeneratorCreator(context -> {
+                    var gen = new 
org.hibernate.id.enhanced.SequenceStyleGenerator();
+                    gen.configure(context.getType(), generatorProps, 
context.getServiceRegistry());
+                    return gen;
+                });
+            }
+        }
+
         if ( propertyConfig.isDerived() && !(property instanceof TenantId)) {
             Formula formula = new Formula();
             formula.setFormula(propertyConfig.getFormula());
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnConfigToColumnBinderSpec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnConfigToColumnBinderSpec.groovy
index 70b8f5a647..d04cd61b9c 100644
--- 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnConfigToColumnBinderSpec.groovy
+++ 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnConfigToColumnBinderSpec.groovy
@@ -69,7 +69,7 @@ class ColumnConfigToColumnBinderSpec extends Specification {
         !column.unique
     }
 
-    def "column config honors uniqueness property"() {
+    def "column config honors uniqueness property when mappedForm is empty"() {
         given:
         def columnConfig = new ColumnConfig()
         columnConfig.length = -1
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinderSpec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinderSpec.groovy
index 6f407dc2ed..e1596e98ca 100644
--- 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinderSpec.groovy
+++ 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinderSpec.groovy
@@ -140,7 +140,7 @@ class SimpleValueBinderSpec extends Specification {
         def owner = Mock(PersistentEntity)
         def mapping = Mock(Mapping)
         def pc = Mock(PropertyConfig)
-        def sv = Mock(SimpleValue)
+        def sv = Mock(org.hibernate.mapping.BasicValue)
         sv.getTable() >> null
         def genProps = new Properties(); 
genProps.setProperty('sequence','seq_name'); genProps.setProperty('foo','bar')
 
@@ -157,8 +157,10 @@ class SimpleValueBinderSpec extends Specification {
         binder.bindSimpleValue(prop, null, sv, null)
 
         then:
-        1 * sv.setIdentifierGeneratorStrategy('sequence')
-        1 * sv.setIdentifierGeneratorProperties({ 
it.getProperty(SequenceStyleGenerator.SEQUENCE_PARAM) == 'seq_name' && 
it.getProperty('foo') == 'bar' })
+        1 * columnBinder.bindColumn(prop, null, _, null, null, null) >> { args 
->
+            args[2].setName("testColumn")
+        }
+        1 * sv.setCustomIdGeneratorCreator(_)
     }
 
     def "binds for each provided column config and adds to table and simple 
value"() {

Reply via email to