This is an automated email from the ASF dual-hosted git repository.

borinquenkid pushed a commit to branch 8.0.x-hibernate7-dev
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 0e03344289fa6a39f904e20dfe3b235242f1f389
Author: Walter Duque de Estrada <[email protected]>
AuthorDate: Tue Mar 3 17:49:14 2026 -0600

    refactor: create SimpleValue inside of simpleValueColumnBinder
---
 .../binder/SimpleValueColumnBinder.java            | 23 ++++++++++++++++++++++
 .../secondpass/BasicCollectionElementBinder.java   |  9 ++++++---
 .../secondpass/ListSecondPassBinder.java           |  5 +----
 .../secondpass/MapSecondPassBinder.java            | 12 +++--------
 4 files changed, 33 insertions(+), 16 deletions(-)

diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/SimpleValueColumnBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/SimpleValueColumnBinder.java
index e2b04f885d..47855078a6 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/SimpleValueColumnBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/SimpleValueColumnBinder.java
@@ -20,8 +20,11 @@ package org.grails.orm.hibernate.cfg.domainbinding.binder;
 
 import java.util.Optional;
 import org.hibernate.MappingException;
+import org.hibernate.boot.spi.MetadataBuildingContext;
+import org.hibernate.mapping.BasicValue;
 import org.hibernate.mapping.Column;
 import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.Table;
 
 public class SimpleValueColumnBinder {
 
@@ -31,6 +34,26 @@ public class SimpleValueColumnBinder {
   /** Protected constructor for testing purposes. */
   protected SimpleValueColumnBinder(Object... ignore) {}
 
+  /**
+   * Creates a {@link BasicValue}, binds it, and returns it.
+   *
+   * @param metadataBuildingContext The metadata building context
+   * @param table The table the value belongs to
+   * @param type The type of the property
+   * @param columnName The column name
+   * @param nullable Whether it is nullable
+   */
+  public BasicValue bindSimpleValue(
+      MetadataBuildingContext metadataBuildingContext,
+      Table table,
+      String type,
+      String columnName,
+      boolean nullable) {
+    BasicValue basicValue = new BasicValue(metadataBuildingContext, table);
+    bindSimpleValue(basicValue, type, columnName, nullable);
+    return basicValue;
+  }
+
   /**
    * Binds a value for the specified parameters to the meta model.
    *
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/BasicCollectionElementBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/BasicCollectionElementBinder.java
index 98918589d3..c9eafa624e 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/BasicCollectionElementBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/BasicCollectionElementBinder.java
@@ -64,7 +64,6 @@ public class BasicCollectionElementBinder {
 
   /** Creates and binds a {@link BasicValue} element for the given basic 
collection property. */
   public BasicValue bind(HibernateToManyProperty property, Collection 
collection) {
-    BasicValue element = new BasicValue(metadataBuildingContext, 
collection.getCollectionTable());
     final Class<?> referencedType = ((Basic) property).getComponentType();
     final boolean isEnum = referencedType.isEnum();
     var joinColumnMappingOptional =
@@ -83,17 +82,21 @@ public class BasicCollectionElementBinder {
                   + new BackticksRemover().apply(clazz);
     }
     if (isEnum) {
+      BasicValue element = new BasicValue(metadataBuildingContext, 
collection.getCollectionTable());
       enumTypeBinder.bindEnumType(property, referencedType, element, 
columnName);
+      return element;
     } else {
       String typeName = property.getTypeName(referencedType);
-      simpleValueColumnBinder.bindSimpleValue(element, typeName, columnName, 
true);
+      BasicValue element =
+          simpleValueColumnBinder.bindSimpleValue(
+              metadataBuildingContext, collection.getCollectionTable(), 
typeName, columnName, true);
       if (joinColumnMappingOptional.isPresent()) {
         Column column = 
simpleValueColumnFetcher.getColumnForSimpleValue(element);
         ColumnConfig columnConfig = joinColumnMappingOptional.get();
         final PropertyConfig mappedForm = property.getMappedForm();
         columnConfigToColumnBinder.bindColumnConfigToColumn(column, 
columnConfig, mappedForm);
       }
+      return element;
     }
-    return element;
   }
 }
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/ListSecondPassBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/ListSecondPassBinder.java
index 9d6cf3d0b1..955cb90a57 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/ListSecondPassBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/ListSecondPassBinder.java
@@ -39,7 +39,6 @@ import org.hibernate.mapping.List;
 import org.hibernate.mapping.ManyToOne;
 import org.hibernate.mapping.OneToMany;
 import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.SimpleValue;
 import org.hibernate.mapping.Table;
 import org.hibernate.mapping.Value;
 
@@ -84,10 +83,8 @@ public class ListSecondPassBinder {
     }
 
     Table collectionTable = list.getCollectionTable();
-    SimpleValue iv = new BasicValue(metadataBuildingContext, collectionTable);
     String type = property.getIndexColumnType("integer");
-    simpleValueColumnBinder.bindSimpleValue(iv, type, columnName, true);
-    iv.setTypeName(type);
+    BasicValue iv = 
simpleValueColumnBinder.bindSimpleValue(metadataBuildingContext, 
collectionTable, type, columnName, true);
     list.setIndex(iv);
     list.setBaseIndex(0);
     list.setInverse(false);
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/MapSecondPassBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/MapSecondPassBinder.java
index 6cc79239ef..2d3b24df62 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/MapSecondPassBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/MapSecondPassBinder.java
@@ -36,7 +36,6 @@ import org.hibernate.boot.spi.InFlightMetadataCollector;
 import org.hibernate.boot.spi.MetadataBuildingContext;
 import org.hibernate.mapping.BasicValue;
 import org.hibernate.mapping.Column;
-import org.hibernate.mapping.SimpleValue;
 import org.hibernate.type.StandardBasicTypes;
 
 /** Refactored from CollectionBinder to handle map second pass binding. */
@@ -70,11 +69,10 @@ public class MapSecondPassBinder {
       Map<?, ?> persistentClasses,
       @Nonnull org.hibernate.mapping.Map map) {
     collectionSecondPassBinder.bindCollectionSecondPass(property, mappings, 
persistentClasses, map);
-    SimpleValue value = new BasicValue(metadataBuildingContext, 
map.getCollectionTable());
 
     String type = property.getIndexColumnType("string");
     String columnName1 = property.getIndexColumnName(namingStrategy);
-    simpleValueColumnBinder.bindSimpleValue(value, type, columnName1, true);
+    BasicValue value = 
simpleValueColumnBinder.bindSimpleValue(metadataBuildingContext, 
map.getCollectionTable(), type, columnName1, true);
     PropertyConfig mappedForm = property.getMappedForm();
     if (mappedForm.getIndexColumn() != null) {
       Column column = simpleValueColumnFetcher.getColumnForSimpleValue(value);
@@ -90,9 +88,6 @@ public class MapSecondPassBinder {
     if (!(property instanceof HibernateOneToManyProperty)
         && !(property instanceof HibernateManyToManyProperty)) {
 
-      SimpleValue elt = new BasicValue(metadataBuildingContext, 
map.getCollectionTable());
-      map.setElement(elt);
-
       String typeName = null;
       if (property instanceof Basic basic) {
         typeName = property.getTypeName(basic.getComponentType());
@@ -105,9 +100,8 @@ public class MapSecondPassBinder {
         typeName = StandardBasicTypes.STRING.getName();
       }
       String columnName = property.getMapElementName(namingStrategy);
-      simpleValueColumnBinder.bindSimpleValue(elt, typeName, columnName, 
false);
-
-      elt.setTypeName(typeName);
+      BasicValue elt = 
simpleValueColumnBinder.bindSimpleValue(metadataBuildingContext, 
map.getCollectionTable(), typeName, columnName, false);
+      map.setElement(elt);
     }
 
     map.setInverse(false);

Reply via email to