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 f40a94429573ccaa2bcf8a65fe3932f8492b92bc
Author: Walter Duque de Estrada <[email protected]>
AuthorDate: Wed Feb 18 21:28:29 2026 -0600

    Further refactor getTypeName and simplify CollectionWithJoinTableBinder 
validation
---
 .../cfg/GrailsHibernatePersistentProperty.java     | 22 ++++++++--------------
 .../secondpass/CollectionWithJoinTableBinder.java  | 10 ----------
 2 files changed, 8 insertions(+), 24 deletions(-)

diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernatePersistentProperty.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernatePersistentProperty.java
index 9e9cf4b1b8..234c0305e0 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernatePersistentProperty.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsHibernatePersistentProperty.java
@@ -86,13 +86,18 @@ public interface GrailsHibernatePersistentProperty extends 
PersistentProperty<Pr
      * @return The type name
      */
     default String getTypeName(Class<?> propertyType, PropertyConfig config, 
Mapping mapping) {
-        if (this instanceof Association) {
+        if (this instanceof Association && propertyType == getType() && 
getHibernateAssociatedEntity() != null) {
             return null;
         }
-        return Optional.ofNullable(config)
+        String typeName = Optional.ofNullable(config)
                 .map(PropertyConfig::getType)
                 .map(typeObj -> typeObj instanceof Class<?> clazz ? 
clazz.getName() : typeObj.toString())
                 .orElseGet(() -> mapping != null ? 
mapping.getTypeName(propertyType) : null);
+
+        if (typeName == null && propertyType != null && 
getHibernateAssociatedEntity() == null) {
+            return propertyType.getName();
+        }
+        return typeName;
     }
 
     default GrailsHibernatePersistentEntity getHibernateOwner() {
@@ -224,18 +229,7 @@ public interface GrailsHibernatePersistentProperty extends 
PersistentProperty<Pr
      * @return The type name
      */
     default String getTypeName(SimpleValue simpleValue) {
-        GrailsHibernatePersistentProperty actualTypeProperty = 
getTypeProperty(simpleValue);
-        String typeName = actualTypeProperty.getTypeName();
-        if (typeName == null) {
-            if (!(actualTypeProperty instanceof Association)) {
-                Class<?> type = actualTypeProperty.getType();
-                if (type != null) {
-                    return type.getName();
-                }
-            }
-            return null;
-        }
-        return typeName;
+        return getTypeProperty(simpleValue).getTypeName();
     }
 
     /**
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionWithJoinTableBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionWithJoinTableBinder.java
index 55a60fa885..ff8598a2dc 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionWithJoinTableBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionWithJoinTableBinder.java
@@ -95,16 +95,6 @@ public class CollectionWithJoinTableBinder {
             else {
 
                 String typeName = property.getTypeName(referencedType);
-                if (typeName == null) {
-                    Type type = 
mappings.getTypeConfiguration().getBasicTypeRegistry().getRegisteredType(className);
-                    if (type != null) {
-                        typeName = type.getName();
-                    }
-                }
-                if (typeName == null) {
-                    String domainName = property.getHibernateOwner().getName();
-                    throw new MappingException("Missing type or column for 
column["+columnName+"] on domain["+domainName+"] referencing["+className+"]");
-                }
 
                 simpleValueColumnBinder.bindSimpleValue(element, typeName, 
columnName, true);
                 if (joinColumnMappingOptional.isPresent()) {

Reply via email to