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 9e8c94925ed55780238a41f03547a2203bf8a067
Author: Walter Duque de Estrada <[email protected]>
AuthorDate: Sun Feb 15 12:34:16 2026 -0600

    Cleanup redundant polymorphic logic in GrailsDomainBinder
    
    - Remove redundant polymorphic check in bindRoot and use children.isEmpty() 
check instead.
    - Remove deprecated setPolymorphic calls in 
bindRootPersistentClassCommonValues and bindDiscriminatorProperty.
---
 .../orm/hibernate/cfg/GrailsDomainBinder.java      | 23 +++++++++-------------
 1 file changed, 9 insertions(+), 14 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 e000e4c45d..8ee1eb3815 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
@@ -277,18 +277,16 @@ public class GrailsDomainBinder
         }
         var children = entity.getChildEntities(dataSourceName);
         RootClass root = bindRootPersistentClassCommonValues(entity, children, 
mappings, sessionFactoryBeanName, identityBinder, versionBinder, 
grailsPropertyBinder, classBinder, propertyFromValueCreator);
-        if (root.isPolymorphic()) {
-            Mapping m = entity.getMappedForm();
-            final Mapping finalMapping = m;
-            boolean tablePerSubclass = !m.getTablePerHierarchy();
-            if (!tablePerSubclass) {
-                // if the root class has children create a discriminator 
property
-
-                bindDiscriminatorProperty(root.getTable(), root, m);
-            }
-            // bind the sub classes
-            children.forEach(sub -> bindSubClass(sub, root, mappings, 
sessionFactoryBeanName, finalMapping,mappingCacheHolder, 
defaultColumnNameFetcher, columnNameForPropertyAndPathFetcher, 
grailsPropertyBinder, classBinder, propertyFromValueCreator, 
multiTenantFilterBinder, joinedSubClassBinder, unionSubclassBinder, 
singleTableSubclassBinder));
+        Mapping m = entity.getMappedForm();
+        final Mapping finalMapping = m;
+        boolean tablePerSubclass = !m.getTablePerHierarchy();
+        if (!children.isEmpty() && !tablePerSubclass) {
+            // if the root class has children create a discriminator property
+
+            bindDiscriminatorProperty(root.getTable(), root, m);
         }
+        // bind the sub classes
+        children.forEach(sub -> bindSubClass(sub, root, mappings, 
sessionFactoryBeanName, finalMapping,mappingCacheHolder, 
defaultColumnNameFetcher, columnNameForPropertyAndPathFetcher, 
grailsPropertyBinder, classBinder, propertyFromValueCreator, 
multiTenantFilterBinder, joinedSubClassBinder, unionSubclassBinder, 
singleTableSubclassBinder));
 
         multiTenantFilterBinder.addMultiTenantFilterIfNecessary(entity, root, 
mappings, defaultColumnNameFetcher);
 
@@ -421,8 +419,6 @@ public class GrailsDomainBinder
                 new ColumnConfigToColumnBinder().bindColumnConfigToColumn(c, 
cc, null);
             }
         }
-
-        entity.setPolymorphic(true);
     }
 
     /*
@@ -441,7 +437,6 @@ public class GrailsDomainBinder
 
         RootClass root = new RootClass(this.metadataBuildingContext);
         root.setAbstract(domainClass.isAbstract());
-        root.setPolymorphic(!children.isEmpty());
         classBinder.bindClass(domainClass, root, mappings);
 
         // get the schema and catalog names from the configuration

Reply via email to