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 de1a641ac24d1ec47048b8ac94867eb5a70b55de
Author: Walter Duque de Estrada <[email protected]>
AuthorDate: Mon Feb 16 15:05:57 2026 -0600

    Encapsulate BasicValue creation within SimpleValueBinder
    
    - Refactor SimpleValueBinder to manage BasicValue instantiation and return 
the bound value.
    - Update GrailsPropertyBinder and ComponentBinder to use the simplified 
binding API.
    - Propagate MetadataBuildingContext dependency through related binders.
    - Update unit tests to align with new constructor and method signatures.
---
 .../orm/hibernate/cfg/GrailsDomainBinder.java      |  3 +-
 .../cfg/domainbinding/binder/CollectionBinder.java |  4 +--
 .../cfg/domainbinding/binder/ComponentBinder.java  |  3 +-
 .../CompositeIdentifierToManyToOneBinder.java      | 11 +++++--
 .../domainbinding/binder/GrailsPropertyBinder.java |  3 +-
 .../cfg/domainbinding/binder/ManyToOneBinder.java  |  7 +----
 .../cfg/domainbinding/binder/OneToOneBinder.java   |  2 +-
 .../domainbinding/binder/SimpleValueBinder.java    | 20 ++++++++++--
 .../cfg/domainbinding/binder/VersionBinder.java    |  2 +-
 .../secondpass/CollectionSecondPassBinder.java     |  4 +--
 .../cfg/domainbinding/CollectionBinderSpec.groovy  |  3 +-
 .../CollectionSecondPassBinderSpec.groovy          |  3 +-
 .../cfg/domainbinding/ComponentBinderSpec.groovy   | 15 +++++----
 ...CompositeIdentifierToManyToOneBinderSpec.groovy |  6 ++--
 .../domainbinding/GrailsPropertyBinderSpec.groovy  |  4 ++-
 .../domainbinding/ListSecondPassBinderSpec.groovy  |  3 +-
 .../domainbinding/MapSecondPassBinderSpec.groovy   |  3 +-
 .../cfg/domainbinding/SimpleValueBinderSpec.groovy | 36 +++++++++++++++++++++-
 18 files changed, 95 insertions(+), 37 deletions(-)

diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java
index 1a33e52ecf..43c7208175 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java
@@ -157,12 +157,13 @@ public class GrailsDomainBinder
         JdbcEnvironment jdbcEnvironment = getJdbcEnvironment();
         DefaultColumnNameFetcher defaultColumnNameFetcher = new 
DefaultColumnNameFetcher(namingStrategy, backticksRemover);
         ColumnNameForPropertyAndPathFetcher 
columnNameForPropertyAndPathFetcher = new 
ColumnNameForPropertyAndPathFetcher(namingStrategy, defaultColumnNameFetcher, 
backticksRemover);
-        SimpleValueBinder simpleValueBinder = new 
SimpleValueBinder(namingStrategy, jdbcEnvironment);
+        SimpleValueBinder simpleValueBinder = new 
SimpleValueBinder(metadataBuildingContext, namingStrategy, jdbcEnvironment);
         EnumTypeBinder enumTypeBinder = new 
EnumTypeBinder(metadataBuildingContext, columnNameForPropertyAndPathFetcher);
         PropertyFromValueCreator propertyFromValueCreator = new 
PropertyFromValueCreator();
         ClassBinder classBinder = new ClassBinder();
         SimpleValueColumnFetcher simpleValueColumnFetcher = new 
SimpleValueColumnFetcher();
         CompositeIdentifierToManyToOneBinder 
compositeIdentifierToManyToOneBinder = new CompositeIdentifierToManyToOneBinder(
+                metadataBuildingContext,
                 new 
org.grails.orm.hibernate.cfg.domainbinding.util.ForeignKeyColumnCountCalculator(),
                 new TableNameFetcher(namingStrategy),
                 namingStrategy,
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/CollectionBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/CollectionBinder.java
index 529ccffbff..46c2ec5d90 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/CollectionBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/CollectionBinder.java
@@ -82,10 +82,10 @@ public class CollectionBinder {
 
     public CollectionBinder(MetadataBuildingContext metadataBuildingContext, 
PersistentEntityNamingStrategy namingStrategy, JdbcEnvironment jdbcEnvironment, 
CollectionHolder collectionHolder) {
         this(metadataBuildingContext, namingStrategy, jdbcEnvironment,
-                new SimpleValueBinder(namingStrategy, jdbcEnvironment),
+                new SimpleValueBinder(metadataBuildingContext, namingStrategy, 
jdbcEnvironment),
                 new EnumTypeBinder(metadataBuildingContext, new 
ColumnNameForPropertyAndPathFetcher(namingStrategy, new 
DefaultColumnNameFetcher(namingStrategy), new BackticksRemover())),
                 new ManyToOneBinder(metadataBuildingContext, namingStrategy, 
jdbcEnvironment),
-                new CompositeIdentifierToManyToOneBinder(namingStrategy, 
jdbcEnvironment),
+                new 
CompositeIdentifierToManyToOneBinder(metadataBuildingContext, namingStrategy, 
jdbcEnvironment),
                 new SimpleValueColumnFetcher(),
                 new ColumnNameForPropertyAndPathFetcher(namingStrategy, new 
DefaultColumnNameFetcher(namingStrategy), new BackticksRemover()),
                 collectionHolder);
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/ComponentBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/ComponentBinder.java
index 8a773dff99..6fcf71d5ba 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/ComponentBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/ComponentBinder.java
@@ -120,8 +120,7 @@ public class ComponentBinder {
             value = bindComponent(persistentClass, embedded, mappings);
         } else {
             //HibernateSimpleProperty
-            value = new BasicValue(metadataBuildingContext, table);
-            this.simpleValueBinder.bindSimpleValue(currentGrailsProp, 
componentProperty, (SimpleValue) value, path);
+            value = this.simpleValueBinder.bindSimpleValue(currentGrailsProp, 
componentProperty, table, path);
         }
         return value;
     }
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/CompositeIdentifierToManyToOneBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/CompositeIdentifierToManyToOneBinder.java
index 28c36e70d3..84f6e45960 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/CompositeIdentifierToManyToOneBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/CompositeIdentifierToManyToOneBinder.java
@@ -4,6 +4,7 @@ import java.util.List;
 
 import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
 import org.hibernate.mapping.SimpleValue;
+import org.hibernate.boot.spi.MetadataBuildingContext;
 
 import org.grails.datastore.mapping.model.PersistentEntity;
 import org.grails.datastore.mapping.model.PersistentProperty;
@@ -21,6 +22,7 @@ import 
org.grails.orm.hibernate.cfg.domainbinding.util.BackticksRemover;
 import static org.grails.orm.hibernate.cfg.GrailsDomainBinder.UNDERSCORE;
 
 public class CompositeIdentifierToManyToOneBinder {
+    private final MetadataBuildingContext metadataBuildingContext;
     private final ForeignKeyColumnCountCalculator 
foreignKeyColumnCountCalculator;
     private final TableNameFetcher tableNameFetcher;
     private final PersistentEntityNamingStrategy namingStrategy;
@@ -29,12 +31,14 @@ public class CompositeIdentifierToManyToOneBinder {
     private final SimpleValueBinder simpleValueBinder;
 
     public CompositeIdentifierToManyToOneBinder(
+            MetadataBuildingContext metadataBuildingContext,
             ForeignKeyColumnCountCalculator foreignKeyColumnCountCalculator,
             TableNameFetcher tableNameFetcher,
             PersistentEntityNamingStrategy namingStrategy,
             DefaultColumnNameFetcher defaultColumnNameFetcher,
             BackticksRemover backticksRemover,
             SimpleValueBinder simpleValueBinder) {
+        this.metadataBuildingContext = metadataBuildingContext;
         this.foreignKeyColumnCountCalculator = foreignKeyColumnCountCalculator;
         this.tableNameFetcher =tableNameFetcher;
         this.namingStrategy = namingStrategy;
@@ -43,13 +47,14 @@ public class CompositeIdentifierToManyToOneBinder {
         this.simpleValueBinder = simpleValueBinder;
     }
 
-    public CompositeIdentifierToManyToOneBinder(PersistentEntityNamingStrategy 
namingStrategy, JdbcEnvironment jdbcEnvironment){
-        this(new ForeignKeyColumnCountCalculator(),
+    public CompositeIdentifierToManyToOneBinder(MetadataBuildingContext 
metadataBuildingContext, PersistentEntityNamingStrategy namingStrategy, 
JdbcEnvironment jdbcEnvironment){
+        this(metadataBuildingContext,
+                new ForeignKeyColumnCountCalculator(),
                 new TableNameFetcher(namingStrategy),
                 namingStrategy,
                 new DefaultColumnNameFetcher(namingStrategy),
                 new BackticksRemover(),
-                new SimpleValueBinder(namingStrategy, jdbcEnvironment));
+                new SimpleValueBinder(metadataBuildingContext, namingStrategy, 
jdbcEnvironment));
     }
 
     public void 
bindCompositeIdentifierToManyToOne(GrailsHibernatePersistentProperty property,
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/GrailsPropertyBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/GrailsPropertyBinder.java
index dbda589d27..e73e55103e 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/GrailsPropertyBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/GrailsPropertyBinder.java
@@ -101,8 +101,7 @@ public class GrailsPropertyBinder {
             value = componentBinder.bindComponent(persistentClass, embedded, 
mappings);
         } else {
             //HibernateSimpleProperty
-            value = new BasicValue(metadataBuildingContext, table);
-            simpleValueBinder.bindSimpleValue(currentGrailsProp, null, 
(SimpleValue) value, EMPTY_PATH);
+            value = simpleValueBinder.bindSimpleValue(currentGrailsProp, null, 
table, EMPTY_PATH);
         }
 
         return value;
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/ManyToOneBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/ManyToOneBinder.java
index 86180cf4ee..da1523e8b7 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/ManyToOneBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/ManyToOneBinder.java
@@ -46,12 +46,7 @@ public class ManyToOneBinder {
     }
 
     public ManyToOneBinder(MetadataBuildingContext metadataBuildingContext, 
PersistentEntityNamingStrategy namingStrategy, JdbcEnvironment jdbcEnvironment) 
{
-        this(metadataBuildingContext,
-                namingStrategy,
-                new SimpleValueBinder(namingStrategy, jdbcEnvironment),
-                new ManyToOneValuesBinder(),
-                new CompositeIdentifierToManyToOneBinder(namingStrategy, 
jdbcEnvironment),
-                new SimpleValueColumnFetcher());
+        this(metadataBuildingContext, namingStrategy, new 
SimpleValueBinder(metadataBuildingContext, namingStrategy, jdbcEnvironment), 
new ManyToOneValuesBinder(), new 
CompositeIdentifierToManyToOneBinder(metadataBuildingContext, namingStrategy, 
jdbcEnvironment), new SimpleValueColumnFetcher());
     }
 
 
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/OneToOneBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/OneToOneBinder.java
index 95ec4b8ec0..c75187ea11 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/OneToOneBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/OneToOneBinder.java
@@ -25,7 +25,7 @@ public class OneToOneBinder {
     }
 
     public OneToOneBinder(MetadataBuildingContext metadataBuildingContext, 
PersistentEntityNamingStrategy namingStrategy, JdbcEnvironment jdbcEnvironment) 
{
-        this(metadataBuildingContext, namingStrategy, new 
SimpleValueBinder(namingStrategy, jdbcEnvironment));
+        this(metadataBuildingContext, namingStrategy, new 
SimpleValueBinder(metadataBuildingContext, namingStrategy, jdbcEnvironment));
     }
 
     public OneToOne bindOneToOne(final 
org.grails.datastore.mapping.model.types.OneToOne property
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/SimpleValueBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/SimpleValueBinder.java
index 9f6ded1bda..cb98774338 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/SimpleValueBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/SimpleValueBinder.java
@@ -6,6 +6,7 @@ import java.util.Properties;
 import org.hibernate.id.enhanced.SequenceStyleGenerator;
 import org.hibernate.generator.Generator;
 import org.hibernate.generator.GeneratorCreationContext;
+import org.hibernate.boot.spi.MetadataBuildingContext;
 import org.hibernate.mapping.BasicValue;
 import org.hibernate.mapping.Column;
 import org.hibernate.mapping.DependantValue;
@@ -25,7 +26,7 @@ import 
org.grails.orm.hibernate.cfg.domainbinding.generator.GrailsSequenceWrappe
 import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
 
 public class SimpleValueBinder {
-
+    private final MetadataBuildingContext metadataBuildingContext;
     private final PersistentEntityNamingStrategy namingStrategy;
     private final ColumnConfigToColumnBinder columnConfigToColumnBinder;
     private final ColumnBinder columnBinder;
@@ -37,11 +38,13 @@ public class SimpleValueBinder {
      * Public constructor that accepts all collaborators.
      */
     public SimpleValueBinder(
+            MetadataBuildingContext metadataBuildingContext,
             PersistentEntityNamingStrategy namingStrategy,
             ColumnConfigToColumnBinder columnConfigToColumnBinder,
             ColumnBinder columnBinder,
             JdbcEnvironment jdbcEnvironment,
             GrailsSequenceWrapper grailsSequenceWrapper) {
+        this.metadataBuildingContext = metadataBuildingContext;
         this.namingStrategy = namingStrategy;
         this.columnConfigToColumnBinder = columnConfigToColumnBinder;
         this.columnBinder = columnBinder;
@@ -52,14 +55,15 @@ public class SimpleValueBinder {
     /**
      * Convenience constructor for namingStrategy.
      */
-    public SimpleValueBinder(PersistentEntityNamingStrategy namingStrategy, 
JdbcEnvironment jdbcEnvironment) {
-        this(namingStrategy, new ColumnConfigToColumnBinder(), new 
ColumnBinder(namingStrategy), jdbcEnvironment, new GrailsSequenceWrapper());
+    public SimpleValueBinder(MetadataBuildingContext metadataBuildingContext, 
PersistentEntityNamingStrategy namingStrategy, JdbcEnvironment jdbcEnvironment) 
{
+        this(metadataBuildingContext, namingStrategy, new 
ColumnConfigToColumnBinder(), new ColumnBinder(namingStrategy), 
jdbcEnvironment, new GrailsSequenceWrapper());
     }
 
     /**
      * Protected constructor for testing purposes.
      */
     protected SimpleValueBinder() {
+        this.metadataBuildingContext = null;
         this.namingStrategy = null;
         this.columnConfigToColumnBinder = null;
         this.columnBinder = null;
@@ -67,6 +71,16 @@ public class SimpleValueBinder {
         this.grailsSequenceWrapper = null;
     }
 
+    public BasicValue bindSimpleValue(
+            @jakarta.annotation.Nonnull GrailsHibernatePersistentProperty 
property,
+            GrailsHibernatePersistentProperty parentProperty,
+            Table table,
+            String path) {
+        BasicValue basicValue = new BasicValue(metadataBuildingContext, table);
+        bindSimpleValue(property, parentProperty, (SimpleValue) basicValue, 
path);
+        return basicValue;
+    }
+
     public void bindSimpleValue(
             @jakarta.annotation.Nonnull GrailsHibernatePersistentProperty 
property,
             GrailsHibernatePersistentProperty parentProperty,
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/VersionBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/VersionBinder.java
index 45b3a08a91..de977377ac 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/VersionBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/VersionBinder.java
@@ -34,7 +34,7 @@ public class VersionBinder {
 
     public VersionBinder(MetadataBuildingContext metadataBuildingContext, 
PersistentEntityNamingStrategy namingStrategy, JdbcEnvironment jdbcEnvironment) 
{
         this(metadataBuildingContext,
-             new SimpleValueBinder(namingStrategy, jdbcEnvironment),
+             new SimpleValueBinder(metadataBuildingContext, namingStrategy, 
jdbcEnvironment),
              new PropertyBinder(),
              BasicValue::new);
     }
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionSecondPassBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionSecondPassBinder.java
index 871097633d..0c5dd65d5b 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionSecondPassBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionSecondPassBinder.java
@@ -81,10 +81,10 @@ public class CollectionSecondPassBinder {
 
     public CollectionSecondPassBinder(MetadataBuildingContext 
metadataBuildingContext, PersistentEntityNamingStrategy namingStrategy, 
JdbcEnvironment jdbcEnvironment) {
         this(metadataBuildingContext, namingStrategy, jdbcEnvironment,
-                new SimpleValueBinder(namingStrategy, jdbcEnvironment),
+                new SimpleValueBinder(metadataBuildingContext, namingStrategy, 
jdbcEnvironment),
                 new EnumTypeBinder(metadataBuildingContext, new 
ColumnNameForPropertyAndPathFetcher(namingStrategy, new 
DefaultColumnNameFetcher(namingStrategy), new BackticksRemover())),
                 new ManyToOneBinder(metadataBuildingContext, namingStrategy, 
jdbcEnvironment),
-                new CompositeIdentifierToManyToOneBinder(namingStrategy, 
jdbcEnvironment),
+                new 
CompositeIdentifierToManyToOneBinder(metadataBuildingContext, namingStrategy, 
jdbcEnvironment),
                 new SimpleValueColumnFetcher());
     }
 
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionBinderSpec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionBinderSpec.groovy
index d472456e5d..2726b07ca5 100644
--- 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionBinderSpec.groovy
+++ 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionBinderSpec.groovy
@@ -54,10 +54,11 @@ class CollectionBinderSpec extends 
HibernateGormDatastoreSpec {
         DefaultColumnNameFetcher defaultColumnNameFetcher = new 
DefaultColumnNameFetcher(namingStrategy, backticksRemover)
         ColumnNameForPropertyAndPathFetcher 
columnNameForPropertyAndPathFetcher = new 
ColumnNameForPropertyAndPathFetcher(namingStrategy, defaultColumnNameFetcher, 
backticksRemover)
         CollectionHolder collectionHolder = new 
CollectionHolder(metadataBuildingContext)
-        SimpleValueBinder simpleValueBinder = new 
SimpleValueBinder(namingStrategy, jdbcEnvironment)
+        SimpleValueBinder simpleValueBinder = new 
SimpleValueBinder(metadataBuildingContext, namingStrategy, jdbcEnvironment)
         EnumTypeBinder enumTypeBinderToUse = new 
EnumTypeBinder(metadataBuildingContext, columnNameForPropertyAndPathFetcher)
         SimpleValueColumnFetcher simpleValueColumnFetcher = new 
SimpleValueColumnFetcher()
         CompositeIdentifierToManyToOneBinder 
compositeIdentifierToManyToOneBinder = new CompositeIdentifierToManyToOneBinder(
+                metadataBuildingContext,
                 new 
org.grails.orm.hibernate.cfg.domainbinding.util.ForeignKeyColumnCountCalculator(),
                 new TableNameFetcher(namingStrategy),
                 namingStrategy,
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionSecondPassBinderSpec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionSecondPassBinderSpec.groovy
index f7e5ff344f..6d4853e5a6 100644
--- 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionSecondPassBinderSpec.groovy
+++ 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionSecondPassBinderSpec.groovy
@@ -53,10 +53,11 @@ class CollectionSecondPassBinderSpec extends 
HibernateGormDatastoreSpec {
         DefaultColumnNameFetcher defaultColumnNameFetcher = new 
DefaultColumnNameFetcher(namingStrategy, backticksRemover)
         ColumnNameForPropertyAndPathFetcher 
columnNameForPropertyAndPathFetcher = new 
ColumnNameForPropertyAndPathFetcher(namingStrategy, defaultColumnNameFetcher, 
backticksRemover)
         CollectionHolder collectionHolder = new 
CollectionHolder(metadataBuildingContext)
-        SimpleValueBinder simpleValueBinder = new 
SimpleValueBinder(namingStrategy, jdbcEnvironment)
+        SimpleValueBinder simpleValueBinder = new 
SimpleValueBinder(metadataBuildingContext, namingStrategy, jdbcEnvironment)
         EnumTypeBinder enumTypeBinderToUse = new 
EnumTypeBinder(metadataBuildingContext, columnNameForPropertyAndPathFetcher)
         SimpleValueColumnFetcher simpleValueColumnFetcher = new 
SimpleValueColumnFetcher()
         CompositeIdentifierToManyToOneBinder 
compositeIdentifierToManyToOneBinder = new CompositeIdentifierToManyToOneBinder(
+                metadataBuildingContext,
                 new 
org.grails.orm.hibernate.cfg.domainbinding.util.ForeignKeyColumnCountCalculator(),
                 new TableNameFetcher(namingStrategy),
                 namingStrategy,
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ComponentBinderSpec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ComponentBinderSpec.groovy
index 62e2571af4..48f9c6a7e2 100644
--- 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ComponentBinderSpec.groovy
+++ 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ComponentBinderSpec.groovy
@@ -93,6 +93,7 @@ class ComponentBinderSpec extends HibernateGormDatastoreSpec {
 
     def setup() {
         def metadataBuildingContext = 
getGrailsDomainBinder().getMetadataBuildingContext()
+        mockSimpleValueBinder = Mock(SimpleValueBinder)
         binder = new ComponentBinder(
                 metadataBuildingContext,
                 mappingCacheHolder,
@@ -154,7 +155,7 @@ class ComponentBinderSpec extends 
HibernateGormDatastoreSpec {
         component.getComponentClassName() == Address.name
         component.getRoleName() == Address.name + ".address"
         1 * mappingCacheHolder.cacheMapping(associatedEntity)
-        1 * mockSimpleValueBinder.bindSimpleValue(prop1, embeddedProp, _ as 
BasicValue, "address")
+        1 * mockSimpleValueBinder.bindSimpleValue(prop1, embeddedProp, _ as 
Table, "address") >> new BasicValue(metadataBuildingContext, root.getTable())
         1 * componentUpdater.updateComponent(_ as Component, embeddedProp, 
prop1, _ as Value)
     }
 
@@ -199,6 +200,7 @@ class ComponentBinderSpec extends 
HibernateGormDatastoreSpec {
         then:
         0 * componentUpdater.updateComponent(_, _, idProp, _)
         0 * componentUpdater.updateComponent(_, _, versionProp, _)
+        1 * mockSimpleValueBinder.bindSimpleValue(normalProp, embeddedProp, _ 
as Table, "address") >> new BasicValue(metadataBuildingContext, root.getTable())
         1 * componentUpdater.updateComponent(_, _, normalProp, _)
     }
 
@@ -236,6 +238,7 @@ class ComponentBinderSpec extends 
HibernateGormDatastoreSpec {
 
         then:
         component.getParentProperty() == "myEntity"
+        0 * mockSimpleValueBinder.bindSimpleValue(parentProp, _, _, _)
         0 * componentUpdater.updateComponent(_, _, parentProp, _)
     }
 
@@ -266,7 +269,7 @@ class ComponentBinderSpec extends 
HibernateGormDatastoreSpec {
         binder.bindComponentProperty(componentProperty, currentGrailsProp, 
root, "address", table, mappings)
 
         then:
-        1 * mockSimpleValueBinder.bindSimpleValue(currentGrailsProp, 
componentProperty, _ as BasicValue, "address")
+        1 * mockSimpleValueBinder.bindSimpleValue(currentGrailsProp, 
componentProperty, table, "address") >> new BasicValue(metadataBuildingContext, 
table)
         0 * componentUpdater.updateComponent(_, _, _, _)
     }
 
@@ -371,7 +374,7 @@ class ComponentBinderSpec extends 
HibernateGormDatastoreSpec {
         binder.bindComponentProperty(componentProperty, currentGrailsProp, 
root, "address", table, mappings)
 
         then:
-        1 * enumTypeBinder.bindEnumType(currentGrailsProp, MyEnum, table, 
"address")
+        1 * enumTypeBinder.bindEnumType(currentGrailsProp, MyEnum, table, 
"address") >> new BasicValue(metadataBuildingContext, table)
         0 * componentUpdater.updateComponent(_, _, _, _)
     }
 
@@ -405,9 +408,9 @@ class ComponentBinderSpec extends 
HibernateGormDatastoreSpec {
         1 * mockSimpleValueBinder.bindSimpleValue(
             currentGrailsProp, 
             componentProperty, 
-            _ as BasicValue, 
+            table, 
             "address"
-        )
+        ) >> new BasicValue(metadataBuildingContext, table)
         0 * componentUpdater.updateComponent(_, _, _, _)
     }
 
@@ -468,7 +471,7 @@ class ComponentBinderSpec extends 
HibernateGormDatastoreSpec {
         result instanceof Component
         result.getComponentClassName() == Address.name
         1 * mappingCacheHolder.cacheMapping(nestedAssociatedEntity)
-        1 * mockSimpleValueBinder.bindSimpleValue(nestedProp1, 
nestedEmbeddedProp, _ as BasicValue, "nestedAddress")
+        1 * mockSimpleValueBinder.bindSimpleValue(nestedProp1, 
nestedEmbeddedProp, _ as Table, "nestedAddress") >> new 
BasicValue(metadataBuildingContext, table)
         1 * componentUpdater.updateComponent(_ as Component, 
nestedEmbeddedProp, nestedProp1, _ as Value)
     }
 
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CompositeIdentifierToManyToOneBinderSpec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CompositeIdentifierToManyToOneBinderSpec.groovy
index 9780a9fc13..6c6ce81a64 100644
--- 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CompositeIdentifierToManyToOneBinderSpec.groovy
+++ 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CompositeIdentifierToManyToOneBinderSpec.groovy
@@ -30,9 +30,10 @@ class CompositeIdentifierToManyToOneBinderSpec extends 
Specification {
         def columnNameFetcher = Stub(DefaultColumnNameFetcher)
         def backticksRemover = Stub(BackticksRemover)
         def simpleValueBinder = Mock(SimpleValueBinder) // Use Mock to verify 
interaction
+        def metadataBuildingContext = 
Mock(org.hibernate.boot.spi.MetadataBuildingContext)
 
         // Instantiate the binder with stubs
-        def binder = new CompositeIdentifierToManyToOneBinder(calculator, 
tableNameFetcher, namingStrategy, columnNameFetcher, backticksRemover, 
simpleValueBinder)
+        def binder = new 
CompositeIdentifierToManyToOneBinder(metadataBuildingContext, calculator, 
tableNameFetcher, namingStrategy, columnNameFetcher, backticksRemover, 
simpleValueBinder)
 
         // 2. Set up stubs for the method arguments
         def association = Stub(ToOne, additionalInterfaces: 
[GrailsHibernatePersistentProperty])
@@ -95,8 +96,9 @@ class CompositeIdentifierToManyToOneBinderSpec extends 
Specification {
         def columnNameFetcher = Mock(DefaultColumnNameFetcher)
         def backticksRemover = Mock(BackticksRemover)
         def simpleValueBinder = Mock(SimpleValueBinder)
+        def metadataBuildingContext = 
Mock(org.hibernate.boot.spi.MetadataBuildingContext)
 
-        def binder = new CompositeIdentifierToManyToOneBinder(calculator, 
tableNameFetcher, namingStrategy, columnNameFetcher, backticksRemover, 
simpleValueBinder)
+        def binder = new 
CompositeIdentifierToManyToOneBinder(metadataBuildingContext, calculator, 
tableNameFetcher, namingStrategy, columnNameFetcher, backticksRemover, 
simpleValueBinder)
 
         // 2. Set up arguments
         def association = Stub(ToOne, additionalInterfaces: 
[GrailsHibernatePersistentProperty])
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/GrailsPropertyBinderSpec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/GrailsPropertyBinderSpec.groovy
index 8a5ef930db..e3d667358a 100644
--- 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/GrailsPropertyBinderSpec.groovy
+++ 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/GrailsPropertyBinderSpec.groovy
@@ -112,10 +112,11 @@ class GrailsPropertyBinderSpec extends 
HibernateGormDatastoreSpec {
         DefaultColumnNameFetcher defaultColumnNameFetcher = new 
DefaultColumnNameFetcher(namingStrategy, backticksRemover)
         ColumnNameForPropertyAndPathFetcher 
columnNameForPropertyAndPathFetcher = new 
ColumnNameForPropertyAndPathFetcher(namingStrategy, defaultColumnNameFetcher, 
backticksRemover)
         CollectionHolder collectionHolder = new 
CollectionHolder(metadataBuildingContext)
-        SimpleValueBinder simpleValueBinder = new 
SimpleValueBinder(namingStrategy, jdbcEnvironment)
+        SimpleValueBinder simpleValueBinder = new 
SimpleValueBinder(metadataBuildingContext, namingStrategy, jdbcEnvironment)
         EnumTypeBinder enumTypeBinderToUse = new 
EnumTypeBinder(metadataBuildingContext, columnNameForPropertyAndPathFetcher)
         SimpleValueColumnFetcher simpleValueColumnFetcher = new 
SimpleValueColumnFetcher()
         CompositeIdentifierToManyToOneBinder 
compositeIdentifierToManyToOneBinder = new CompositeIdentifierToManyToOneBinder(
+                metadataBuildingContext,
                 new 
org.grails.orm.hibernate.cfg.domainbinding.util.ForeignKeyColumnCountCalculator(),
                 new TableNameFetcher(namingStrategy),
                 namingStrategy,
@@ -535,6 +536,7 @@ class GrailsPropertyBinderSpec extends 
HibernateGormDatastoreSpec {
         // Mocking other necessary properties of currentGrailsProp
         currentGrailsProp.getType() >> String.class
         currentGrailsProp.getName() >> "title"
+        simpleValueBinder.bindSimpleValue(currentGrailsProp, null, table, 
EMPTY_PATH) >> new BasicValue(metadataBuildingContext, table)
 
         when:
         // Capture the return value of bindProperty
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ListSecondPassBinderSpec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ListSecondPassBinderSpec.groovy
index 5dde40379c..7fcd5ac386 100644
--- 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ListSecondPassBinderSpec.groovy
+++ 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ListSecondPassBinderSpec.groovy
@@ -53,10 +53,11 @@ class ListSecondPassBinderSpec extends 
HibernateGormDatastoreSpec {
         DefaultColumnNameFetcher defaultColumnNameFetcher = new 
DefaultColumnNameFetcher(namingStrategy, backticksRemover)
         ColumnNameForPropertyAndPathFetcher 
columnNameForPropertyAndPathFetcher = new 
ColumnNameForPropertyAndPathFetcher(namingStrategy, defaultColumnNameFetcher, 
backticksRemover)
         CollectionHolder collectionHolder = new 
CollectionHolder(metadataBuildingContext)
-        SimpleValueBinder simpleValueBinder = new 
SimpleValueBinder(namingStrategy, jdbcEnvironment)
+        SimpleValueBinder simpleValueBinder = new 
SimpleValueBinder(metadataBuildingContext, namingStrategy, jdbcEnvironment)
         EnumTypeBinder enumTypeBinderToUse = new 
EnumTypeBinder(metadataBuildingContext, columnNameForPropertyAndPathFetcher)
         SimpleValueColumnFetcher simpleValueColumnFetcher = new 
SimpleValueColumnFetcher()
         CompositeIdentifierToManyToOneBinder 
compositeIdentifierToManyToOneBinder = new CompositeIdentifierToManyToOneBinder(
+                metadataBuildingContext,
                 new 
org.grails.orm.hibernate.cfg.domainbinding.util.ForeignKeyColumnCountCalculator(),
                 new TableNameFetcher(namingStrategy),
                 namingStrategy,
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/MapSecondPassBinderSpec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/MapSecondPassBinderSpec.groovy
index 026943763d..2b18aac309 100644
--- 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/MapSecondPassBinderSpec.groovy
+++ 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/MapSecondPassBinderSpec.groovy
@@ -53,10 +53,11 @@ class MapSecondPassBinderSpec extends 
HibernateGormDatastoreSpec {
         DefaultColumnNameFetcher defaultColumnNameFetcher = new 
DefaultColumnNameFetcher(namingStrategy, backticksRemover)
         ColumnNameForPropertyAndPathFetcher 
columnNameForPropertyAndPathFetcher = new 
ColumnNameForPropertyAndPathFetcher(namingStrategy, defaultColumnNameFetcher, 
backticksRemover)
         CollectionHolder collectionHolder = new 
CollectionHolder(metadataBuildingContext)
-        SimpleValueBinder simpleValueBinder = new 
SimpleValueBinder(namingStrategy, jdbcEnvironment)
+        SimpleValueBinder simpleValueBinder = new 
SimpleValueBinder(metadataBuildingContext, namingStrategy, jdbcEnvironment)
         EnumTypeBinder enumTypeBinderToUse = new 
EnumTypeBinder(metadataBuildingContext, columnNameForPropertyAndPathFetcher)
         SimpleValueColumnFetcher simpleValueColumnFetcher = new 
SimpleValueColumnFetcher()
         CompositeIdentifierToManyToOneBinder 
compositeIdentifierToManyToOneBinder = new CompositeIdentifierToManyToOneBinder(
+                metadataBuildingContext,
                 new 
org.grails.orm.hibernate.cfg.domainbinding.util.ForeignKeyColumnCountCalculator(),
                 new TableNameFetcher(namingStrategy),
                 namingStrategy,
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 8943e11823..f23bf3ddc6 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
@@ -31,8 +31,10 @@ class SimpleValueBinderSpec extends Specification {
     def columnBinder = Mock(ColumnBinder)
     def jdbcEnvironment = 
Mock(org.hibernate.engine.jdbc.env.spi.JdbcEnvironment)
     def grailsSequenceWrapper = 
Mock(org.grails.orm.hibernate.cfg.domainbinding.generator.GrailsSequenceWrapper)
+    def metadataBuildingContext = 
Mock(org.hibernate.boot.spi.MetadataBuildingContext)
 
-    def binder = new SimpleValueBinder(namingStrategy,
+    def binder = new SimpleValueBinder(metadataBuildingContext,
+            namingStrategy,
             columnConfigToColumnBinder,
             columnBinder,
             jdbcEnvironment,
@@ -231,4 +233,36 @@ class SimpleValueBinderSpec extends Specification {
         }
         2 * sv.addColumn(_ as Column)
     }
+
+    def "bindSimpleValue creates and returns BasicValue"() {
+        given:
+        def prop = Mock(GrailsHibernatePersistentProperty)
+        def owner = Mock(GrailsHibernatePersistentEntity)
+        def mapping = Mock(Mapping)
+        def pc = Mock(PropertyConfig)
+        def table = new org.hibernate.mapping.Table("test_table")
+        def mappings = Mock(org.hibernate.boot.spi.InFlightMetadataCollector)
+        metadataBuildingContext.getMetadataCollector() >> mappings
+
+        prop.getMappedForm() >> pc
+        prop.getOwner() >> owner
+        owner.getMappedForm() >> mapping
+        prop.getTypeName(_ as SimpleValue) >> String.name
+        pc.isDerived() >> false
+        pc.getColumns() >> null
+        prop.getType() >> String
+        prop.isNullable() >> true
+
+        when:
+        def result = binder.bindSimpleValue(prop, null, table, "path")
+
+        then:
+        1 * columnBinder.bindColumn(prop, null, _, null, "path", table) >> { 
args ->
+            def column = args[2] as Column
+            column.setName("testColumn")
+        }
+        result instanceof org.hibernate.mapping.BasicValue
+        result.getTable() == table
+        result.getTypeName() == String.name
+    }
 }


Reply via email to