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 31424104eb27777335259e5069c54bee7f6cc240 Author: Walter Duque de Estrada <[email protected]> AuthorDate: Sat Feb 14 18:18:41 2026 -0600 Refactor GrailsDomainBinder to use local variables for remaining binders and utilities - Remove classBinding, enumTypeBinder, and propertyFromValueCreator fields from GrailsDomainBinder. - Instantiate ClassBinder, EnumTypeBinder, and PropertyFromValueCreator as local variables in the contribute method. - Update binding method signatures to propagate these local dependencies. - Retain only the 3-argument constructor and initialize MappingCacheHolder within it. - Update unit tests to reflect the changed method signatures and removed getters. --- .../orm/hibernate/cfg/GrailsDomainBinder.java | 100 ++++++++------------- .../domainbinding/secondpass/SetSecondPass.java | 2 + .../cfg/domainbinding/CollectionBinderSpec.groovy | 3 +- .../CollectionSecondPassBinderSpec.groovy | 3 +- .../domainbinding/GrailsPropertyBinderSpec.groovy | 19 ++-- .../domainbinding/ListSecondPassBinderSpec.groovy | 3 +- .../domainbinding/MapSecondPassBinderSpec.groovy | 3 +- 7 files changed, 57 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 3d35c5a9cc..e1588603a8 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 @@ -125,31 +125,22 @@ public class GrailsDomainBinder private final String sessionFactoryName; private final String dataSourceName; private final HibernateMappingContext hibernateMappingContext; - private final ClassBinder classBinding; - private final EnumTypeBinder enumTypeBinder; - private final PropertyFromValueCreator propertyFromValueCreator; - private ComponentPropertyBinder componentPropertyBinder; - private Closure defaultMapping; private PersistentEntityNamingStrategy namingStrategy; private MetadataBuildingContext metadataBuildingContext; - private MappingCacheHolder mappingCacheHolder; + private final MappingCacheHolder mappingCacheHolder; public JdbcEnvironment getJdbcEnvironment() { return metadataBuildingContext.getMetadataCollector().getDatabase().getJdbcEnvironment(); } - public GrailsDomainBinder(String dataSourceName - , String sessionFactoryName - , HibernateMappingContext hibernateMappingContext - , ClassBinder classBinding - , EnumTypeBinder enumTypeBinder) { + public GrailsDomainBinder( + String dataSourceName, + String sessionFactoryName, + HibernateMappingContext hibernateMappingContext) { this.sessionFactoryName = sessionFactoryName; this.dataSourceName = dataSourceName; this.hibernateMappingContext = hibernateMappingContext; - this.classBinding = classBinding; - this.enumTypeBinder = enumTypeBinder; - this.propertyFromValueCreator = new PropertyFromValueCreator(); this.mappingCacheHolder = MappingCacheHolder.getInstance(); // pre-build mappings @@ -161,22 +152,6 @@ public class GrailsDomainBinder - public GrailsDomainBinder( - String dataSourceName, - String sessionFactoryName, - HibernateMappingContext hibernateMappingContext) { - this(dataSourceName - , sessionFactoryName - , hibernateMappingContext - , new ClassBinder() - , new EnumTypeBinder() - ); - - } - - - - @Override public void contribute(AdditionalMappingContributions contributions, InFlightMetadataCollector metadataCollector, ResourceStreamLocator resourceStreamLocator, MetadataBuildingContext buildingContext) { this.metadataBuildingContext = new MetadataBuildingContextRootImpl( @@ -193,7 +168,9 @@ public class GrailsDomainBinder DefaultColumnNameFetcher defaultColumnNameFetcher = new DefaultColumnNameFetcher(namingStrategy, backticksRemover); ColumnNameForPropertyAndPathFetcher columnNameForPropertyAndPathFetcher = new ColumnNameForPropertyAndPathFetcher(namingStrategy, defaultColumnNameFetcher, backticksRemover); SimpleValueBinder simpleValueBinder = new SimpleValueBinder(namingStrategy, jdbcEnvironment); - EnumTypeBinder enumTypeBinderToUse = enumTypeBinder != null ? enumTypeBinder : new EnumTypeBinder(); + EnumTypeBinder enumTypeBinder = new EnumTypeBinder(); + PropertyFromValueCreator propertyFromValueCreator = new PropertyFromValueCreator(); + ClassBinder classBinder = new ClassBinder(); SimpleValueColumnFetcher simpleValueColumnFetcher = new SimpleValueColumnFetcher(); CompositeIdentifierToManyToOneBinder compositeIdentifierToManyToOneBinder = new CompositeIdentifierToManyToOneBinder( new org.grails.orm.hibernate.cfg.domainbinding.util.ForeignKeyColumnCountCalculator(), @@ -211,7 +188,7 @@ public class GrailsDomainBinder namingStrategy, jdbcEnvironment, simpleValueBinder, - enumTypeBinderToUse, + enumTypeBinder, manyToOneBinder, compositeIdentifierToManyToOneBinder, simpleValueColumnFetcher @@ -222,7 +199,7 @@ public class GrailsDomainBinder jdbcEnvironment, getMappingCacheHolder(), collectionHolder, - enumTypeBinderToUse, + enumTypeBinder, collectionBinder, propertyFromValueCreator, null, @@ -235,7 +212,7 @@ public class GrailsDomainBinder metadataBuildingContext, namingStrategy, collectionHolder, - enumTypeBinderToUse, + enumTypeBinder, componentPropertyBinder, collectionBinder, simpleValueBinder, @@ -254,7 +231,7 @@ public class GrailsDomainBinder .getHibernatePersistentEntities(dataSourceName) .stream() .filter(persistentEntity -> persistentEntity.forGrailsDomainMapping(dataSourceName)) - .forEach(hibernatePersistentEntity -> bindRoot(hibernatePersistentEntity, metadataCollector, sessionFactoryName, defaultColumnNameFetcher, columnNameForPropertyAndPathFetcher, identityBinder, versionBinder, grailsPropertyBinder)); + .forEach(hibernatePersistentEntity -> bindRoot(hibernatePersistentEntity, metadataCollector, sessionFactoryName, defaultColumnNameFetcher, columnNameForPropertyAndPathFetcher, identityBinder, versionBinder, grailsPropertyBinder, classBinder, propertyFromValueCreator)); } @@ -285,13 +262,13 @@ public class GrailsDomainBinder * @param mappings The Hibernate Mappings object * @param sessionFactoryBeanName the session factory bean name */ - protected void bindRoot(@Nonnull GrailsHibernatePersistentEntity entity,@Nonnull InFlightMetadataCollector mappings, String sessionFactoryBeanName, DefaultColumnNameFetcher defaultColumnNameFetcher, ColumnNameForPropertyAndPathFetcher columnNameForPropertyAndPathFetcher, IdentityBinder identityBinder, VersionBinder versionBinder, GrailsPropertyBinder grailsPropertyBinder) { + protected void bindRoot(@Nonnull GrailsHibernatePersistentEntity entity,@Nonnull InFlightMetadataCollector mappings, String sessionFactoryBeanName, DefaultColumnNameFetcher defaultColumnNameFetcher, ColumnNameForPropertyAndPathFetcher columnNameForPropertyAndPathFetcher, IdentityBinder identityBinder, VersionBinder versionBinder, GrailsPropertyBinder grailsPropertyBinder, ClassBinder classBinder, PropertyFromValueCreator propertyFromValueCreator) { if (mappings.getEntityBinding(entity.getName()) != null) { LOG.info("[GrailsDomainBinder] Class [" + entity.getName() + "] is already mapped, skipping.. "); return; } var children = entity.getChildEntities(dataSourceName); - RootClass root = bindRootPersistentClassCommonValues(entity, children, mappings, sessionFactoryBeanName, identityBinder, versionBinder, grailsPropertyBinder); + RootClass root = bindRootPersistentClassCommonValues(entity, children, mappings, sessionFactoryBeanName, identityBinder, versionBinder, grailsPropertyBinder, classBinder, propertyFromValueCreator); if (root.isPolymorphic()) { Mapping m = entity.getMappedForm(); final Mapping finalMapping = m; @@ -302,7 +279,7 @@ public class GrailsDomainBinder bindDiscriminatorProperty(root.getTable(), root, m); } // bind the sub classes - children.forEach(sub -> bindSubClass(sub, root, mappings, sessionFactoryBeanName, finalMapping,mappingCacheHolder, defaultColumnNameFetcher, columnNameForPropertyAndPathFetcher, grailsPropertyBinder )); + children.forEach(sub -> bindSubClass(sub, root, mappings, sessionFactoryBeanName, finalMapping,mappingCacheHolder, defaultColumnNameFetcher, columnNameForPropertyAndPathFetcher, grailsPropertyBinder, classBinder, propertyFromValueCreator )); } addMultiTenantFilterIfNecessary(entity, root, mappings, defaultColumnNameFetcher); @@ -373,9 +350,9 @@ public class GrailsDomainBinder PersistentClass parent, @Nonnull InFlightMetadataCollector mappings, String sessionFactoryBeanName - , Mapping m, MappingCacheHolder mappingCacheHolder, DefaultColumnNameFetcher defaultColumnNameFetcher, ColumnNameForPropertyAndPathFetcher columnNameForPropertyAndPathFetcher, GrailsPropertyBinder grailsPropertyBinder) { + , Mapping m, MappingCacheHolder mappingCacheHolder, DefaultColumnNameFetcher defaultColumnNameFetcher, ColumnNameForPropertyAndPathFetcher columnNameForPropertyAndPathFetcher, GrailsPropertyBinder grailsPropertyBinder, ClassBinder classBinder, PropertyFromValueCreator propertyFromValueCreator) { mappingCacheHolder.cacheMapping(sub); - Subclass subClass = createSubclassMapping(sub, parent, mappings, sessionFactoryBeanName, m, defaultColumnNameFetcher, columnNameForPropertyAndPathFetcher, grailsPropertyBinder); + Subclass subClass = createSubclassMapping(sub, parent, mappings, sessionFactoryBeanName, m, defaultColumnNameFetcher, columnNameForPropertyAndPathFetcher, grailsPropertyBinder, classBinder, propertyFromValueCreator); parent.addSubclass(subClass); @@ -386,25 +363,25 @@ public class GrailsDomainBinder var children = sub.getChildEntities(dataSourceName); if (!children.isEmpty()) { // bind the sub classes - children.forEach(sub1 -> bindSubClass(sub1, subClass, mappings, sessionFactoryBeanName, m,mappingCacheHolder, defaultColumnNameFetcher, columnNameForPropertyAndPathFetcher, grailsPropertyBinder )); + children.forEach(sub1 -> bindSubClass(sub1, subClass, mappings, sessionFactoryBeanName, m,mappingCacheHolder, defaultColumnNameFetcher, columnNameForPropertyAndPathFetcher, grailsPropertyBinder, classBinder, propertyFromValueCreator )); } } - private @NonNull Subclass createSubclassMapping(@NonNull GrailsHibernatePersistentEntity subEntity, PersistentClass parent, @NonNull InFlightMetadataCollector mappings, String sessionFactoryBeanName, Mapping m, DefaultColumnNameFetcher defaultColumnNameFetcher, ColumnNameForPropertyAndPathFetcher columnNameForPropertyAndPathFetcher, GrailsPropertyBinder grailsPropertyBinder) { + private @NonNull Subclass createSubclassMapping(@NonNull GrailsHibernatePersistentEntity subEntity, PersistentClass parent, @NonNull InFlightMetadataCollector mappings, String sessionFactoryBeanName, Mapping m, DefaultColumnNameFetcher defaultColumnNameFetcher, ColumnNameForPropertyAndPathFetcher columnNameForPropertyAndPathFetcher, GrailsPropertyBinder grailsPropertyBinder, ClassBinder classBinder, PropertyFromValueCreator propertyFromValueCreator) { Subclass subClass; subEntity.configureDerivedProperties(); if (!m.getTablePerHierarchy() && !m.isTablePerConcreteClass()) { subClass = new JoinedSubclass(parent, this.metadataBuildingContext); - bindJoinedSubClass(subEntity, (JoinedSubclass) subClass, mappings, sessionFactoryBeanName, columnNameForPropertyAndPathFetcher, grailsPropertyBinder); + bindJoinedSubClass(subEntity, (JoinedSubclass) subClass, mappings, sessionFactoryBeanName, columnNameForPropertyAndPathFetcher, grailsPropertyBinder, classBinder, propertyFromValueCreator); } else if(m.isTablePerConcreteClass()) { subClass = new UnionSubclass(parent, this.metadataBuildingContext); - bindUnionSubclass(subEntity, (UnionSubclass) subClass, mappings, sessionFactoryBeanName, grailsPropertyBinder); + bindUnionSubclass(subEntity, (UnionSubclass) subClass, mappings, sessionFactoryBeanName, grailsPropertyBinder, classBinder, propertyFromValueCreator); } else { subClass = new SingleTableSubclass(parent, this.metadataBuildingContext); subClass.setDiscriminatorValue(subEntity.getDiscriminatorValue()); - bindSubClass(subEntity, subClass, mappings, sessionFactoryBeanName, defaultColumnNameFetcher, grailsPropertyBinder); + bindSubClass(subEntity, subClass, mappings, sessionFactoryBeanName, defaultColumnNameFetcher, grailsPropertyBinder, classBinder, propertyFromValueCreator); } subClass.setBatchSize(Optional.ofNullable(m.getBatchSize()).orElse(-1)); subClass.setDynamicUpdate(m.getDynamicUpdate()); @@ -418,8 +395,8 @@ public class GrailsDomainBinder private void bindUnionSubclass(@Nonnull GrailsHibernatePersistentEntity subClass, UnionSubclass unionSubclass, - @Nonnull InFlightMetadataCollector mappings, String sessionFactoryBeanName, GrailsPropertyBinder grailsPropertyBinder) throws MappingException { - classBinding.bindClass(subClass, unionSubclass, mappings); + @Nonnull InFlightMetadataCollector mappings, String sessionFactoryBeanName, GrailsPropertyBinder grailsPropertyBinder, ClassBinder classBinder, PropertyFromValueCreator propertyFromValueCreator) throws MappingException { + classBinder.bindClass(subClass, unionSubclass, mappings); String schema = subClass.getSchema(mappings); String catalog = subClass.getCatalog(mappings); @@ -441,7 +418,7 @@ public class GrailsDomainBinder " -> " + unionSubclass.getTable().getName() ); - createClassProperties(subClass, unionSubclass, mappings, sessionFactoryBeanName, grailsPropertyBinder); + createClassProperties(subClass, unionSubclass, mappings, sessionFactoryBeanName, grailsPropertyBinder, propertyFromValueCreator); } /** @@ -453,8 +430,8 @@ public class GrailsDomainBinder * @param sessionFactoryBeanName the session factory bean name */ private void bindJoinedSubClass(GrailsHibernatePersistentEntity sub, JoinedSubclass joinedSubclass, - InFlightMetadataCollector mappings, String sessionFactoryBeanName, ColumnNameForPropertyAndPathFetcher columnNameForPropertyAndPathFetcher, GrailsPropertyBinder grailsPropertyBinder) { - classBinding.bindClass(sub, joinedSubclass, mappings); + InFlightMetadataCollector mappings, String sessionFactoryBeanName, ColumnNameForPropertyAndPathFetcher columnNameForPropertyAndPathFetcher, GrailsPropertyBinder grailsPropertyBinder, ClassBinder classBinder, PropertyFromValueCreator propertyFromValueCreator) { + classBinder.bindClass(sub, joinedSubclass, mappings); String schemaName = sub.getSchema(mappings); String catalogName = sub.getCatalog(mappings); @@ -478,7 +455,7 @@ public class GrailsDomainBinder joinedSubclass.createForeignKey(); // properties - createClassProperties(sub, joinedSubclass, mappings, sessionFactoryBeanName, grailsPropertyBinder); + createClassProperties(sub, joinedSubclass, mappings, sessionFactoryBeanName, grailsPropertyBinder, propertyFromValueCreator); } private String getJoinedSubClassTableName( @@ -503,15 +480,15 @@ public class GrailsDomainBinder * @param mappings The mappings instance */ private void bindSubClass(@Nonnull GrailsHibernatePersistentEntity sub, Subclass subClass, @Nonnull InFlightMetadataCollector mappings, - String sessionFactoryBeanName, DefaultColumnNameFetcher defaultColumnNameFetcher, GrailsPropertyBinder grailsPropertyBinder) { - classBinding.bindClass(sub, subClass, mappings); + String sessionFactoryBeanName, DefaultColumnNameFetcher defaultColumnNameFetcher, GrailsPropertyBinder grailsPropertyBinder, ClassBinder classBinder, PropertyFromValueCreator propertyFromValueCreator) { + classBinder.bindClass(sub, subClass, mappings); if (LOG.isDebugEnabled()) LOG.debug("Mapping subclass: " + subClass.getEntityName() + " -> " + subClass.getTable().getName()); // properties - createClassProperties(sub, subClass, mappings, sessionFactoryBeanName, grailsPropertyBinder); + createClassProperties(sub, subClass, mappings, sessionFactoryBeanName, grailsPropertyBinder, propertyFromValueCreator); } /** @@ -576,13 +553,15 @@ public class GrailsDomainBinder String sessionFactoryBeanName, IdentityBinder identityBinder, VersionBinder versionBinder, - GrailsPropertyBinder grailsPropertyBinder + GrailsPropertyBinder grailsPropertyBinder, + ClassBinder classBinder, + PropertyFromValueCreator propertyFromValueCreator ) { RootClass root = new RootClass(this.metadataBuildingContext); root.setAbstract(domainClass.isAbstract()); root.setPolymorphic(!children.isEmpty()); - classBinding.bindClass(domainClass, root, mappings); + classBinder.bindClass(domainClass, root, mappings); // get the schema and catalog names from the configuration Mapping gormMapping = domainClass.getMappedForm(); @@ -625,7 +604,7 @@ public class GrailsDomainBinder identityBinder.bindIdentity(domainClass, root, mappings, gormMapping, sessionFactoryBeanName); versionBinder.bindVersion(domainClass.getVersion(), root); root.createPrimaryKey(); - createClassProperties(domainClass, root, mappings, sessionFactoryBeanName, grailsPropertyBinder); + createClassProperties(domainClass, root, mappings, sessionFactoryBeanName, grailsPropertyBinder, propertyFromValueCreator); return root; } @@ -641,7 +620,7 @@ public class GrailsDomainBinder * @param sessionFactoryBeanName the session factory bean name */ private void createClassProperties(@Nonnull GrailsHibernatePersistentEntity domainClass, PersistentClass persistentClass, - @Nonnull InFlightMetadataCollector mappings, String sessionFactoryBeanName, GrailsPropertyBinder grailsPropertyBinder) { + @Nonnull InFlightMetadataCollector mappings, String sessionFactoryBeanName, GrailsPropertyBinder grailsPropertyBinder, PropertyFromValueCreator propertyFromValueCreator) { @@ -664,11 +643,6 @@ public class GrailsDomainBinder } - public PropertyFromValueCreator getPropertyFromValueCreator() { - return propertyFromValueCreator; - } - - @Override public String getContributorName() { return "GORM"; diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/SetSecondPass.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/SetSecondPass.java index 09cc80dfbc..b3c7c5416c 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/SetSecondPass.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/SetSecondPass.java @@ -1,5 +1,6 @@ package org.grails.orm.hibernate.cfg.domainbinding.secondpass; +import java.io.Serial; import java.util.Map; import jakarta.annotation.Nonnull; @@ -19,6 +20,7 @@ import org.grails.orm.hibernate.cfg.domainbinding.hibernate.HibernateToManyPrope */ public class SetSecondPass implements org.hibernate.boot.spi.SecondPass, GrailsSecondPass { + @Serial private static final long serialVersionUID = -5540526942092611348L; private final CollectionSecondPassBinder collectionSecondPassBinder; diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionBinderSpec.groovy index 84aaf1f6be..9f8b6969c4 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionBinderSpec.groovy @@ -17,6 +17,7 @@ import org.grails.orm.hibernate.cfg.domainbinding.binder.CompositeIdentifierToMa import org.grails.orm.hibernate.cfg.domainbinding.util.SimpleValueColumnFetcher import org.grails.orm.hibernate.cfg.domainbinding.util.TableNameFetcher import org.grails.orm.hibernate.cfg.domainbinding.binder.CollectionBinder +import org.grails.orm.hibernate.cfg.domainbinding.binder.ClassBinder import org.grails.orm.hibernate.cfg.domainbinding.binder.OneToOneBinder import org.grails.orm.hibernate.cfg.GrailsDomainBinder @@ -116,7 +117,7 @@ class CollectionBinderSpec extends HibernateGormDatastoreSpec { protected void bindRoot(GrailsDomainBinder binder, GrailsHibernatePersistentEntity entity, InFlightMetadataCollector mappings, String sessionFactoryBeanName) { def binders = getBinders(binder) - binder.bindRoot(entity, mappings, sessionFactoryBeanName, binders.defaultColumnNameFetcher, binders.columnNameForPropertyAndPathFetcher, binders.identityBinder as IdentityBinder, binders.versionBinder as VersionBinder, binders.propertyBinder as GrailsPropertyBinder) + binder.bindRoot(entity, mappings, sessionFactoryBeanName, binders.defaultColumnNameFetcher, binders.columnNameForPropertyAndPathFetcher, binders.identityBinder as IdentityBinder, binders.versionBinder as VersionBinder, binders.propertyBinder as GrailsPropertyBinder, new ClassBinder(), new PropertyFromValueCreator()) } void setupSpec() { diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionSecondPassBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionSecondPassBinderSpec.groovy index 2bf547279e..5c4163b15f 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionSecondPassBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CollectionSecondPassBinderSpec.groovy @@ -26,6 +26,7 @@ import org.grails.orm.hibernate.cfg.GrailsDomainBinder import org.grails.orm.hibernate.cfg.domainbinding.secondpass.CollectionSecondPassBinder import org.grails.orm.hibernate.cfg.domainbinding.binder.OneToOneBinder +import org.grails.orm.hibernate.cfg.domainbinding.binder.ClassBinder import org.grails.orm.hibernate.cfg.domainbinding.binder.ComponentPropertyBinder import org.grails.orm.hibernate.cfg.domainbinding.util.BasicValueIdCreator import org.grails.orm.hibernate.cfg.domainbinding.binder.GrailsPropertyBinder @@ -118,7 +119,7 @@ class CollectionSecondPassBinderSpec extends HibernateGormDatastoreSpec { protected void bindRoot(GrailsDomainBinder binder, GrailsHibernatePersistentEntity entity, InFlightMetadataCollector mappings, String sessionFactoryBeanName) { def binders = getBinders(binder) - binder.bindRoot(entity, mappings, sessionFactoryBeanName, binders.defaultColumnNameFetcher, binders.columnNameForPropertyAndPathFetcher, binders.identityBinder as IdentityBinder, binders.versionBinder as VersionBinder, binders.propertyBinder as GrailsPropertyBinder) + binder.bindRoot(entity, mappings, sessionFactoryBeanName, binders.defaultColumnNameFetcher, binders.columnNameForPropertyAndPathFetcher, binders.identityBinder as IdentityBinder, binders.versionBinder as VersionBinder, binders.propertyBinder as GrailsPropertyBinder, new ClassBinder(), new PropertyFromValueCreator()) } void setupSpec() { diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/GrailsPropertyBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/GrailsPropertyBinderSpec.groovy index e90f4c1a0b..75f29d47b5 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/GrailsPropertyBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/GrailsPropertyBinderSpec.groovy @@ -12,6 +12,7 @@ import org.hibernate.mapping.SimpleValue import org.hibernate.mapping.Value import org.grails.orm.hibernate.cfg.domainbinding.binder.CollectionBinder +import org.grails.orm.hibernate.cfg.domainbinding.binder.ClassBinder import org.grails.orm.hibernate.cfg.domainbinding.binder.ComponentPropertyBinder import org.grails.orm.hibernate.cfg.domainbinding.binder.EnumTypeBinder import org.grails.orm.hibernate.cfg.domainbinding.binder.GrailsPropertyBinder @@ -122,7 +123,7 @@ class GrailsPropertyBinderSpec extends HibernateGormDatastoreSpec { protected void bindRoot(GrailsDomainBinder binder, GrailsHibernatePersistentEntity entity, InFlightMetadataCollector mappings, String sessionFactoryBeanName) { def binders = getBinders(binder) - binder.bindRoot(entity, mappings, sessionFactoryBeanName, binders.defaultColumnNameFetcher, binders.columnNameForPropertyAndPathFetcher, binders.identityBinder as IdentityBinder, binders.versionBinder as VersionBinder, binders.propertyBinder as GrailsPropertyBinder) + binder.bindRoot(entity, mappings, sessionFactoryBeanName, binders.defaultColumnNameFetcher, binders.columnNameForPropertyAndPathFetcher, binders.identityBinder as IdentityBinder, binders.versionBinder as VersionBinder, binders.propertyBinder as GrailsPropertyBinder, new ClassBinder(), new PropertyFromValueCreator()) } void setupSpec() { @@ -148,7 +149,7 @@ class GrailsPropertyBinderSpec extends HibernateGormDatastoreSpec { when: def titleProp = persistentEntity.getPropertyByName("title") as GrailsHibernatePersistentProperty Value value = propertyBinder.bindProperty(rootClass, titleProp, collector, "sessionFactory") - rootClass.addProperty(binder.getPropertyFromValueCreator().createProperty(value, titleProp)) + rootClass.addProperty(new PropertyFromValueCreator().createProperty(value, titleProp)) then: Property prop = rootClass.getProperty("title") @@ -170,7 +171,7 @@ class GrailsPropertyBinderSpec extends HibernateGormDatastoreSpec { when: def statusProp = persistentEntity.getPropertyByName("status") as GrailsHibernatePersistentProperty Value value = propertyBinder.bindProperty(rootClass, statusProp, collector, "sessionFactory") - rootClass.addProperty(binder.getPropertyFromValueCreator().createProperty(value, statusProp)) + rootClass.addProperty(new PropertyFromValueCreator().createProperty(value, statusProp)) then: Property prop = rootClass.getProperty("status") @@ -196,7 +197,7 @@ class GrailsPropertyBinderSpec extends HibernateGormDatastoreSpec { when: def ownerProp = petEntity.getPropertyByName("owner") as GrailsHibernatePersistentProperty Value value = propertyBinder.bindProperty(rootClass, ownerProp, collector, "sessionFactory") - rootClass.addProperty(binder.getPropertyFromValueCreator().createProperty(value, ownerProp)) + rootClass.addProperty(new PropertyFromValueCreator().createProperty(value, ownerProp)) then: Property prop = rootClass.getProperty("owner") @@ -219,7 +220,7 @@ class GrailsPropertyBinderSpec extends HibernateGormDatastoreSpec { when: def addressProp = persistentEntity.getPropertyByName("homeAddress") as GrailsHibernatePersistentProperty Value value = propertyBinder.bindProperty(rootClass, addressProp, collector, "sessionFactory") - rootClass.addProperty(binder.getPropertyFromValueCreator().createProperty(value, addressProp)) + rootClass.addProperty(new PropertyFromValueCreator().createProperty(value, addressProp)) then: Property prop = rootClass.getProperty("homeAddress") @@ -247,7 +248,7 @@ class GrailsPropertyBinderSpec extends HibernateGormDatastoreSpec { when: def petsProp = personEntity.getPropertyByName("pets") as GrailsHibernatePersistentProperty Value value = propertyBinder.bindProperty(rootClass, petsProp, collector, "sessionFactory") - rootClass.addProperty(binder.getPropertyFromValueCreator().createProperty(value, petsProp)) + rootClass.addProperty(new PropertyFromValueCreator().createProperty(value, petsProp)) then: Property prop = rootClass.getProperty("pets") @@ -286,7 +287,7 @@ class GrailsPropertyBinderSpec extends HibernateGormDatastoreSpec { when: def booksProp = authorEntity.getPropertyByName("books") as GrailsHibernatePersistentProperty Value value = propertyBinder.bindProperty(rootClass, booksProp, collector, "sessionFactory") - rootClass.addProperty(binder.getPropertyFromValueCreator().createProperty(value, booksProp)) + rootClass.addProperty(new PropertyFromValueCreator().createProperty(value, booksProp)) collector.processSecondPasses(binder.getMetadataBuildingContext()) then: @@ -325,7 +326,7 @@ class GrailsPropertyBinderSpec extends HibernateGormDatastoreSpec { when: def booksProp = authorEntity.getPropertyByName("books") as GrailsHibernatePersistentProperty Value value = propertyBinder.bindProperty(rootClass, booksProp, collector, "sessionFactory") - rootClass.addProperty(binder.getPropertyFromValueCreator().createProperty(value, booksProp)) + rootClass.addProperty(new PropertyFromValueCreator().createProperty(value, booksProp)) collector.processSecondPasses(binder.getMetadataBuildingContext()) then: @@ -386,7 +387,7 @@ class GrailsPropertyBinderSpec extends HibernateGormDatastoreSpec { when: def childBookProp = authorEntity.getPropertyByName("childBook") as GrailsHibernatePersistentProperty Value value = propertyBinder.bindProperty(rootClass, childBookProp, collector, "sessionFactory") - rootClass.addProperty(binder.getPropertyFromValueCreator().createProperty(value, childBookProp)) + rootClass.addProperty(new PropertyFromValueCreator().createProperty(value, childBookProp)) // Process second passes to ensure Hibernate's internal mappings are finalized collector.processSecondPasses(binder.getMetadataBuildingContext()) diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ListSecondPassBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ListSecondPassBinderSpec.groovy index 1270d45e57..94ce5a94b0 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ListSecondPassBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ListSecondPassBinderSpec.groovy @@ -28,6 +28,7 @@ import org.grails.orm.hibernate.cfg.domainbinding.secondpass.CollectionSecondPas import org.grails.orm.hibernate.cfg.domainbinding.secondpass.ListSecondPassBinder import org.grails.orm.hibernate.cfg.domainbinding.binder.OneToOneBinder +import org.grails.orm.hibernate.cfg.domainbinding.binder.ClassBinder import org.grails.orm.hibernate.cfg.domainbinding.binder.ComponentPropertyBinder import org.grails.orm.hibernate.cfg.domainbinding.util.BasicValueIdCreator import org.grails.orm.hibernate.cfg.domainbinding.binder.GrailsPropertyBinder @@ -120,7 +121,7 @@ class ListSecondPassBinderSpec extends HibernateGormDatastoreSpec { protected void bindRoot(GrailsDomainBinder binder, GrailsHibernatePersistentEntity entity, InFlightMetadataCollector mappings, String sessionFactoryBeanName) { def binders = getBinders(binder) - binder.bindRoot(entity, mappings, sessionFactoryBeanName, binders.defaultColumnNameFetcher, binders.columnNameForPropertyAndPathFetcher, binders.identityBinder as IdentityBinder, binders.versionBinder as VersionBinder, binders.propertyBinder as GrailsPropertyBinder) + binder.bindRoot(entity, mappings, sessionFactoryBeanName, binders.defaultColumnNameFetcher, binders.columnNameForPropertyAndPathFetcher, binders.identityBinder as IdentityBinder, binders.versionBinder as VersionBinder, binders.propertyBinder as GrailsPropertyBinder, new ClassBinder(), new PropertyFromValueCreator()) } void setupSpec() { diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/MapSecondPassBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/MapSecondPassBinderSpec.groovy index e07ffd467f..033e1f3a9f 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/MapSecondPassBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/MapSecondPassBinderSpec.groovy @@ -28,6 +28,7 @@ import org.grails.orm.hibernate.cfg.domainbinding.secondpass.CollectionSecondPas import org.grails.orm.hibernate.cfg.domainbinding.secondpass.MapSecondPassBinder import org.grails.orm.hibernate.cfg.domainbinding.binder.OneToOneBinder +import org.grails.orm.hibernate.cfg.domainbinding.binder.ClassBinder import org.grails.orm.hibernate.cfg.domainbinding.binder.ComponentPropertyBinder import org.grails.orm.hibernate.cfg.domainbinding.util.BasicValueIdCreator import org.grails.orm.hibernate.cfg.domainbinding.binder.GrailsPropertyBinder @@ -120,7 +121,7 @@ class MapSecondPassBinderSpec extends HibernateGormDatastoreSpec { protected void bindRoot(GrailsDomainBinder binder, GrailsHibernatePersistentEntity entity, InFlightMetadataCollector mappings, String sessionFactoryBeanName) { def binders = getBinders(binder) - binder.bindRoot(entity, mappings, sessionFactoryBeanName, binders.defaultColumnNameFetcher, binders.columnNameForPropertyAndPathFetcher, binders.identityBinder as IdentityBinder, binders.versionBinder as VersionBinder, binders.propertyBinder as GrailsPropertyBinder) + binder.bindRoot(entity, mappings, sessionFactoryBeanName, binders.defaultColumnNameFetcher, binders.columnNameForPropertyAndPathFetcher, binders.identityBinder as IdentityBinder, binders.versionBinder as VersionBinder, binders.propertyBinder as GrailsPropertyBinder, new ClassBinder(), new PropertyFromValueCreator()) } void setupSpec() {
