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 c7db53b77e16ba33558f17c3500fbeedcbacb30e
Author: Walter B Duque de Estrada <[email protected]>
AuthorDate: Fri Jan 30 16:27:28 2026 -0600

    childEntities
---
 .../orm/hibernate/cfg/GrailsDomainBinder.java      | 156 +++++++++++----------
 1 file changed, 80 insertions(+), 76 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 de0e44bbdb..3752e574d8 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
@@ -39,6 +39,7 @@ import org.grails.orm.hibernate.cfg.domainbinding.*;
 import 
org.grails.orm.hibernate.cfg.domainbinding.collectionType.CollectionHolder;
 import 
org.grails.orm.hibernate.cfg.domainbinding.collectionType.CollectionType;
 
+import org.checkerframework.checker.nullness.qual.NonNull;
 import org.hibernate.FetchMode;
 import org.hibernate.MappingException;
 import org.hibernate.boot.ResourceStreamLocator;
@@ -1533,106 +1534,109 @@ public class GrailsDomainBinder
 
 
         for (PersistentProperty<?> currentGrailsProp : persistentProperties) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("[GrailsDomainBinder] Binding persistent property [" 
+ currentGrailsProp.getName() + "]");
-            }
+            bindProperty(persistentClass, mappings, sessionFactoryBeanName, 
currentGrailsProp, table, gormMapping);
+        }
 
-            Value value = null;
+        new NaturalIdentifierBinder().bindNaturalIdentifier(gormMapping, 
persistentClass);
+    }
 
-            // see if it's a collection type
-            CollectionType collectionType = 
collectionHolder.get(currentGrailsProp.getType());
+    private void bindProperty(PersistentClass persistentClass, @NonNull 
InFlightMetadataCollector mappings, String sessionFactoryBeanName, 
PersistentProperty<?> currentGrailsProp, Table table, Mapping gormMapping) {
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("[GrailsDomainBinder] Binding persistent property [" + 
currentGrailsProp.getName() + "]");
+        }
 
-            Class<?> userType = getUserType(currentGrailsProp);
+        Value value = null;
 
-            if (userType != null && 
!UserCollectionType.class.isAssignableFrom(userType)) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("[GrailsDomainBinder] Binding property [" + 
currentGrailsProp.getName() + "] as SimpleValue");
-                }
-                value = new BasicValue(metadataBuildingContext, table);
-                // set type
-                new 
SimpleValueBinder(namingStrategy).bindSimpleValue(currentGrailsProp, null, 
(SimpleValue) value, EMPTY_PATH);
-            }
-            else if (collectionType != null) {
-                String typeName = new 
TypeNameProvider().getTypeName(currentGrailsProp, gormMapping);
-                if ("serializable".equals(typeName)) {
-                    value = new BasicValue(metadataBuildingContext, table);
-                    boolean nullable = currentGrailsProp.isNullable();
-                    String columnName = new 
ColumnNameForPropertyAndPathFetcher(namingStrategy).getColumnNameForPropertyAndPath(currentGrailsProp,
 EMPTY_PATH, null);
-                    new 
SimpleValueColumnBinder().bindSimpleValue((SimpleValue) value, typeName, 
columnName, nullable);
-                }
-                else {
-                    // create collection
-                    Collection collection = collectionType.create((ToMany) 
currentGrailsProp, persistentClass,
-                            EMPTY_PATH, mappings, sessionFactoryBeanName);
-                    mappings.addCollectionBinding(collection);
-                    value = collection;
-                }
+        // see if it's a collection type
+        CollectionType collectionType = 
collectionHolder.get(currentGrailsProp.getType());
+
+        Class<?> userType = getUserType(currentGrailsProp);
+
+        if (userType != null && 
!UserCollectionType.class.isAssignableFrom(userType)) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("[GrailsDomainBinder] Binding property [" + 
currentGrailsProp.getName() + "] as SimpleValue");
             }
-            else if (currentGrailsProp.getType().isEnum()) {
+            value = new BasicValue(metadataBuildingContext, table);
+            // set type
+            new 
SimpleValueBinder(namingStrategy).bindSimpleValue(currentGrailsProp, null, 
(SimpleValue) value, EMPTY_PATH);
+        }
+        else if (collectionType != null) {
+            String typeName = new 
TypeNameProvider().getTypeName(currentGrailsProp, gormMapping);
+            if ("serializable".equals(typeName)) {
                 value = new BasicValue(metadataBuildingContext, table);
+                boolean nullable = currentGrailsProp.isNullable();
                 String columnName = new 
ColumnNameForPropertyAndPathFetcher(namingStrategy).getColumnNameForPropertyAndPath(currentGrailsProp,
 EMPTY_PATH, null);
-                enumTypeBinder.bindEnumType(currentGrailsProp, 
currentGrailsProp.getType(), (SimpleValue) value, columnName);
+                new SimpleValueColumnBinder().bindSimpleValue((SimpleValue) 
value, typeName, columnName, nullable);
+            }
+            else {
+                // create collection
+                Collection collection = collectionType.create((ToMany) 
currentGrailsProp, persistentClass,
+                        EMPTY_PATH, mappings, sessionFactoryBeanName);
+                mappings.addCollectionBinding(collection);
+                value = collection;
+            }
+        }
+        else if (currentGrailsProp.getType().isEnum()) {
+            value = new BasicValue(metadataBuildingContext, table);
+            String columnName = new 
ColumnNameForPropertyAndPathFetcher(namingStrategy).getColumnNameForPropertyAndPath(currentGrailsProp,
 EMPTY_PATH, null);
+            enumTypeBinder.bindEnumType(currentGrailsProp, 
currentGrailsProp.getType(), (SimpleValue) value, columnName);
+        }
+        else if(currentGrailsProp instanceof Association) {
+            Association association = (Association) currentGrailsProp;
+            if (currentGrailsProp instanceof 
org.grails.datastore.mapping.model.types.ManyToOne) {
+                if (LOG.isDebugEnabled())
+                    LOG.debug("[GrailsDomainBinder] Binding property [" + 
currentGrailsProp.getName() + "] as ManyToOne");
+
+                value = new ManyToOne(metadataBuildingContext, table);
+                new 
ManyToOneBinder(namingStrategy).bindManyToOne((Association) currentGrailsProp, 
(ManyToOne) value, EMPTY_PATH);
             }
-            else if(currentGrailsProp instanceof Association) {
-                Association association = (Association) currentGrailsProp;
-                if (currentGrailsProp instanceof 
org.grails.datastore.mapping.model.types.ManyToOne) {
-                    if (LOG.isDebugEnabled())
-                        LOG.debug("[GrailsDomainBinder] Binding property [" + 
currentGrailsProp.getName() + "] as ManyToOne");
-
-                    value = new ManyToOne(metadataBuildingContext, table);
-                    new 
ManyToOneBinder(namingStrategy).bindManyToOne((Association) currentGrailsProp, 
(ManyToOne) value, EMPTY_PATH);
+            else if (currentGrailsProp instanceof 
org.grails.datastore.mapping.model.types.OneToOne && userType == null) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("[GrailsDomainBinder] Binding property [" + 
currentGrailsProp.getName() + "] as OneToOne");
                 }
-                else if (currentGrailsProp instanceof 
org.grails.datastore.mapping.model.types.OneToOne && userType == null) {
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("[GrailsDomainBinder] Binding property [" + 
currentGrailsProp.getName() + "] as OneToOne");
-                    }
 
-                    final boolean isHasOne = association.isHasOne();
-                    if (isHasOne && !association.isBidirectional()) {
-                        throw new MappingException("hasOne property [" + 
currentGrailsProp.getOwner().getName() +
-                                "." + currentGrailsProp.getName() + "] is not 
bidirectional. Specify the other side of the relationship!");
-                    }
-                    else if (((Association) 
currentGrailsProp).canBindOneToOneWithSingleColumnAndForeignKey()) {
+                final boolean isHasOne = association.isHasOne();
+                if (isHasOne && !association.isBidirectional()) {
+                    throw new MappingException("hasOne property [" + 
currentGrailsProp.getOwner().getName() +
+                            "." + currentGrailsProp.getName() + "] is not 
bidirectional. Specify the other side of the relationship!");
+                }
+                else if (((Association) 
currentGrailsProp).canBindOneToOneWithSingleColumnAndForeignKey()) {
+                    value = new OneToOne(metadataBuildingContext, table, 
persistentClass);
+                    new 
OneToOneBinder(namingStrategy).bindOneToOne((org.grails.datastore.mapping.model.types.OneToOne)
 currentGrailsProp, (OneToOne) value, EMPTY_PATH);
+                }
+                else {
+                    if (isHasOne && association.isBidirectional()) {
                         value = new OneToOne(metadataBuildingContext, table, 
persistentClass);
                         new 
OneToOneBinder(namingStrategy).bindOneToOne((org.grails.datastore.mapping.model.types.OneToOne)
 currentGrailsProp, (OneToOne) value, EMPTY_PATH);
                     }
                     else {
-                        if (isHasOne && association.isBidirectional()) {
-                            value = new OneToOne(metadataBuildingContext, 
table, persistentClass);
-                            new 
OneToOneBinder(namingStrategy).bindOneToOne((org.grails.datastore.mapping.model.types.OneToOne)
 currentGrailsProp, (OneToOne) value, EMPTY_PATH);
-                        }
-                        else {
-                            value = new ManyToOne(metadataBuildingContext, 
table);
-                            new 
ManyToOneBinder(namingStrategy).bindManyToOne((Association) currentGrailsProp, 
(ManyToOne) value, EMPTY_PATH);
-                        }
+                        value = new ManyToOne(metadataBuildingContext, table);
+                        new 
ManyToOneBinder(namingStrategy).bindManyToOne((Association) currentGrailsProp, 
(ManyToOne) value, EMPTY_PATH);
                     }
                 }
-                else if (currentGrailsProp instanceof Embedded) {
-                    value = new Component(metadataBuildingContext, 
persistentClass);
-                    componentPropertyBinder.bindComponent((Component) value, 
(Embedded) currentGrailsProp, true, mappings, sessionFactoryBeanName);
-                }
             }
-            // work out what type of relationship it is and bind value
-            else {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("[GrailsDomainBinder] Binding property [" + 
currentGrailsProp.getName() + "] as SimpleValue");
-                }
-                value = new BasicValue(metadataBuildingContext, table);
-                // set type
-                new 
SimpleValueBinder(namingStrategy).bindSimpleValue(currentGrailsProp, null, 
(SimpleValue) value, EMPTY_PATH);
+            else if (currentGrailsProp instanceof Embedded) {
+                value = new Component(metadataBuildingContext, 
persistentClass);
+                componentPropertyBinder.bindComponent((Component) value, 
(Embedded) currentGrailsProp, true, mappings, sessionFactoryBeanName);
             }
-
-            if (value != null) {
-                Property property = 
propertyFromValueCreator.createProperty(value, currentGrailsProp);
-                persistentClass.addProperty(property);
+        }
+        // work out what type of relationship it is and bind value
+        else {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("[GrailsDomainBinder] Binding property [" + 
currentGrailsProp.getName() + "] as SimpleValue");
             }
+            value = new BasicValue(metadataBuildingContext, table);
+            // set type
+            new 
SimpleValueBinder(namingStrategy).bindSimpleValue(currentGrailsProp, null, 
(SimpleValue) value, EMPTY_PATH);
         }
 
-        new NaturalIdentifierBinder().bindNaturalIdentifier(gormMapping, 
persistentClass);
+        if (value != null) {
+            Property property = propertyFromValueCreator.createProperty(value, 
currentGrailsProp);
+            persistentClass.addProperty(property);
+        }
     }
 
 
-
     private void 
bindOneToMany(org.grails.datastore.mapping.model.types.OneToMany 
currentGrailsProp, OneToMany one, @Nonnull InFlightMetadataCollector mappings) {
         
one.setReferencedEntityName(currentGrailsProp.getAssociatedEntity().getName());
         one.setIgnoreNotFound(true);

Reply via email to