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 5b369575e4dbfe07e62e51c9d9e940b691b998bd Author: Walter Duque de Estrada <[email protected]> AuthorDate: Mon Mar 16 09:37:28 2026 -0500 hibernate 7 temp --- .../cfg/domainbinding/binder/CollectionBinder.java | 13 ++++++++----- .../cfg/domainbinding/collectionType/CollectionType.java | 1 + .../hibernate/HibernatePersistentProperty.java | 9 +++++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/CollectionBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/CollectionBinder.java index 40197a3f0c..148a4cdf29 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/CollectionBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/CollectionBinder.java @@ -32,6 +32,7 @@ import org.grails.orm.hibernate.cfg.PersistentEntityNamingStrategy; import org.grails.orm.hibernate.cfg.PropertyConfig; import org.grails.orm.hibernate.cfg.domainbinding.collectionType.CollectionHolder; import org.grails.orm.hibernate.cfg.domainbinding.collectionType.CollectionType; +import org.grails.orm.hibernate.cfg.domainbinding.hibernate.GrailsHibernatePersistentEntity; import org.grails.orm.hibernate.cfg.domainbinding.hibernate.HibernateOneToManyProperty; import org.grails.orm.hibernate.cfg.domainbinding.hibernate.HibernatePersistentProperty; import org.grails.orm.hibernate.cfg.domainbinding.hibernate.HibernateToManyProperty; @@ -134,18 +135,20 @@ public class CollectionBinder { * First pass to bind collection to Hibernate metamodel, sets up second pass * * @param property The GrailsDomainClassProperty instance - * @param owner The owning persistent class + * @param persistentClass The owning persistent class * @param path The property path * @return the result */ - public Collection bindCollection(HibernateToManyProperty property, PersistentClass owner, String path) { + public Collection bindCollection(HibernateToManyProperty property, PersistentClass persistentClass, String path) { + GrailsHibernatePersistentEntity owner = property.getHibernateOwner(); + PersistentClass _persistentClass = owner.getPersistentClass(); CollectionType collectionType = collectionHolder.get(property.getType()); - Collection collection = collectionType.create(property, owner); + Collection collection = collectionType.create(property, _persistentClass); property.setCollection(collection); // set role String propertyName = getNameForPropertyAndPath(property, path); - collection.setRole(GrailsHibernateUtil.qualify(property.getOwner().getName(), propertyName)); + collection.setRole(GrailsHibernateUtil.qualify(owner.getName(), propertyName)); PropertyConfig pc = property.getMappedForm(); // configure eager fetching @@ -167,7 +170,7 @@ public class CollectionBinder { collection.setElement(oneToMany); bindOneToMany((HibernateOneToManyProperty) property, oneToMany); } else { - bindCollectionTable(property, owner.getTable()); + bindCollectionTable(property, _persistentClass.getTable()); if (property.isBidirectional()) { if (!property.isOwningSide()) { diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/collectionType/CollectionType.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/collectionType/CollectionType.java index fc0963f3c3..add61d72d5 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/collectionType/CollectionType.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/collectionType/CollectionType.java @@ -43,6 +43,7 @@ public abstract class CollectionType { /** Create. */ public Collection create(HibernateToManyProperty property, PersistentClass owner) throws MappingException { + property.getPersistentClass(); Collection coll = createCollection(owner); coll.setCollectionTable(owner.getTable()); coll.setTypeName(getTypeName(property)); diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernatePersistentProperty.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernatePersistentProperty.java index 34dc1526f4..6aa8b07051 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernatePersistentProperty.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/hibernate/HibernatePersistentProperty.java @@ -22,6 +22,7 @@ import java.util.Optional; import org.checkerframework.checker.nullness.qual.Nullable; import org.hibernate.mapping.DependantValue; +import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.Table; @@ -103,7 +104,7 @@ public interface HibernatePersistentProperty extends PersistentProperty<Property } default GrailsHibernatePersistentEntity getHibernateOwner() { - return getOwner() instanceof GrailsHibernatePersistentEntity ghpe ? ghpe : null; + return (GrailsHibernatePersistentEntity )getOwner() ; } @SuppressWarnings("PMD.DataflowAnomalyAnalysis") @@ -206,6 +207,10 @@ public interface HibernatePersistentProperty extends PersistentProperty<Property } default Table getTable() { - return getHibernateOwner().getPersistentClass().getTable(); + return getPersistentClass().getTable(); + } + + default PersistentClass getPersistentClass(){ + return getHibernateOwner().getPersistentClass(); } }
