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 7df3fa02652eba665bed0d314f41de564696f172
Author: Walter Duque de Estrada <[email protected]>
AuthorDate: Wed Feb 25 13:06:50 2026 -0600

    cleaning up getTypeName
---
 .../grails/orm/hibernate/cfg/PropertyConfig.groovy |  8 +++
 .../GrailsHibernatePersistentProperty.java         | 69 +++++++++++-----------
 2 files changed, 41 insertions(+), 36 deletions(-)

diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/PropertyConfig.groovy
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/PropertyConfig.groovy
index ff8f16611e..52e3d3dc92 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/PropertyConfig.groovy
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/PropertyConfig.groovy
@@ -433,6 +433,14 @@ class PropertyConfig extends Property {
         return columns[0].scale
     }
 
+    /**
+     * @return The type name
+     */
+     String getTypeName() {
+        return type?.with { it instanceof Class ? it.name : it.toString() };
+    }
+
+
     @Override
     void setScale(int scale) {
         checkHasSingleColumn()
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/GrailsHibernatePersistentProperty.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/GrailsHibernatePersistentProperty.java
index feffc7fd5a..3063d09c06 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/GrailsHibernatePersistentProperty.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/GrailsHibernatePersistentProperty.java
@@ -19,6 +19,8 @@
 package org.grails.orm.hibernate.cfg.domainbinding.hibernate;
 
 import java.util.Optional;
+
+import static java.util.Optional.ofNullable;
 import org.grails.datastore.mapping.model.PersistentProperty;
 import org.grails.datastore.mapping.model.types.Association;
 import org.grails.datastore.mapping.model.types.Embedded;
@@ -41,15 +43,15 @@ public interface GrailsHibernatePersistentProperty extends 
PersistentProperty<Pr
 
   default HibernateAssociation getHibernateInverseSide() {
     return this instanceof Association<?> association
-        ? (HibernateAssociation) association.getInverseSide()
-        : null;
+            ? (HibernateAssociation) association.getInverseSide()
+            : null;
   }
 
 
   default GrailsHibernatePersistentEntity getHibernateAssociatedEntity() {
     return this instanceof Association<?> association
-        ? (GrailsHibernatePersistentEntity) association.getAssociatedEntity()
-        : null;
+            ? (GrailsHibernatePersistentEntity) 
association.getAssociatedEntity()
+            : null;
   }
 
   /**
@@ -83,19 +85,14 @@ public interface GrailsHibernatePersistentProperty extends 
PersistentProperty<Pr
    * @return The type name
    */
   default String getTypeName(Class<?> propertyType, PropertyConfig config, 
Mapping mapping) {
-    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
-        && !propertyType.isEnum()) {
-      return propertyType.getName();
-    }
-    return typeName;
+
+    return ofNullable(config)
+            .map(PropertyConfig::getTypeName)
+            .orElseGet(() -> ofNullable(mapping).map(__ -> 
__.getTypeName(propertyType))
+                    .orElseGet(() -> Optional.ofNullable(propertyType)
+                            .filter(__ -> !__.isEnum())
+                            .map(Class::getName)
+                            .orElse(null)));
   }
 
   default GrailsHibernatePersistentEntity getHibernateOwner() {
@@ -143,18 +140,18 @@ public interface GrailsHibernatePersistentProperty 
extends PersistentProperty<Pr
   default void validateAssociation() {
     if (this instanceof Association && getUserType() != null) {
       throw new MappingException(
-          "Cannot bind association property ["
-              + getName()
-              + "] of type ["
-              + getType()
-              + "] to a user type");
+              "Cannot bind association property ["
+                      + getName()
+                      + "] of type ["
+                      + getType()
+                      + "] to a user type");
     }
     if (this instanceof org.grails.datastore.mapping.model.types.OneToOne 
oneToOne) {
       if (oneToOne.isHasOne() && !oneToOne.isBidirectional()) {
         throw new MappingException(
-            "hasOne property ["
-                + getName()
-                + "] is not bidirectional. Specify the other side of the 
relationship!");
+                "hasOne property ["
+                        + getName()
+                        + "] is not bidirectional. Specify the other side of 
the relationship!");
       }
     }
   }
@@ -168,8 +165,8 @@ public interface GrailsHibernatePersistentProperty extends 
PersistentProperty<Pr
    */
   default boolean isJoinKeyMapped() {
     return getMappedForm() != null
-        && getMappedForm().hasJoinKeyMapping()
-        && supportsJoinColumnMapping();
+            && getMappedForm().hasJoinKeyMapping()
+            && supportsJoinColumnMapping();
   }
 
   default String getMappedColumnName() {
@@ -181,13 +178,13 @@ public interface GrailsHibernatePersistentProperty 
extends PersistentProperty<Pr
 
   default String getColumnName(ColumnConfig cc) {
     return Optional.of(this)
-        .filter(GrailsHibernatePersistentProperty::isJoinKeyMapped)
-        .map(p -> p.getMappedForm().getJoinTable().getKey().getName())
-        .orElseGet(
-            () ->
-                Optional.ofNullable(cc)
-                    .map(ColumnConfig::getName)
-                    .orElseGet(this::getMappedColumnName));
+            .filter(GrailsHibernatePersistentProperty::isJoinKeyMapped)
+            .map(p -> p.getMappedForm().getJoinTable().getKey().getName())
+            .orElseGet(
+                    () ->
+                            Optional.ofNullable(cc)
+                                    .map(ColumnConfig::getName)
+                                    .orElseGet(this::getMappedColumnName));
   }
 
   /**
@@ -205,8 +202,8 @@ public interface GrailsHibernatePersistentProperty extends 
PersistentProperty<Pr
   default java.util.Properties getTypeParameters(SimpleValue simpleValue) {
     if (getTypeName(simpleValue) != null) {
       return Optional.ofNullable(getTypeProperty(simpleValue).getMappedForm())
-          .map(PropertyConfig::getTypeParams)
-          .orElse(null);
+              .map(PropertyConfig::getTypeParams)
+              .orElse(null);
     }
     return null;
   }

Reply via email to