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 34afefea63bc2cd8ee511826190fa8f7833717a2 Author: Walter Duque de Estrada <[email protected]> AuthorDate: Tue Feb 10 10:54:53 2026 -0600 consolidated the SimpleValueBinder.bindSimpleValue method into a single signature and updated all its callers. --- .../domainbinding/ColumnConfigToColumnBinder.java | 42 ++++++++------- .../cfg/domainbinding/ComponentPropertyBinder.java | 12 +++-- .../cfg/domainbinding/ManyToOneBinder.java | 4 +- .../cfg/domainbinding/OneToOneBinder.java | 2 +- .../cfg/domainbinding/SimpleIdBinder.java | 3 +- .../cfg/domainbinding/SimpleValueBinder.java | 30 +++++------ .../hibernate/cfg/domainbinding/VersionBinder.java | 3 +- .../secondpass/CollectionSecondPassBinder.java | 4 +- .../ComponentPropertyBinderSpec.groovy | 62 +++++++++++++++------- ...CompositeIdentifierToManyToOneBinderSpec.groovy | 4 +- .../cfg/domainbinding/ManyToOneBinderSpec.groovy | 4 +- .../cfg/domainbinding/SimpleIdBinderSpec.groovy | 4 +- .../cfg/domainbinding/SimpleValueBinderSpec.groovy | 2 +- .../cfg/domainbinding/VersionBinderSpec.groovy | 9 ++-- 14 files changed, 106 insertions(+), 79 deletions(-) diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnConfigToColumnBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnConfigToColumnBinder.java index f6c360af07..0e6428d173 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnConfigToColumnBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ColumnConfigToColumnBinder.java @@ -11,27 +11,29 @@ public class ColumnConfigToColumnBinder { public void bindColumnConfigToColumn( @Nonnull Column column, - @Nonnull ColumnConfig columnConfig, + ColumnConfig columnConfig, PropertyConfig mappedForm ) { - Optional.of(columnConfig.getLength()) - .filter(l -> l != -1) - .ifPresent(column::setLength); - - Optional.of(columnConfig.getPrecision()) - .filter(p -> p != -1) - .ifPresent(column::setPrecision); - - Optional.of(columnConfig.getScale()) - .filter(s -> s != -1) - .ifPresent(column::setScale); - - Optional.ofNullable(columnConfig.getSqlType()) - .filter(s -> !s.isEmpty()) - .ifPresent(column::setSqlType); - - Optional.ofNullable(mappedForm) - .filter(mf -> !mf.isUniqueWithinGroup()) - .ifPresent(mf -> column.setUnique(columnConfig.getUnique())); + Optional.ofNullable(columnConfig).ifPresent(config -> { + Optional.of(config.getLength()) + .filter(l -> l != -1) + .ifPresent(column::setLength); + + Optional.of(config.getPrecision()) + .filter(p -> p != -1) + .ifPresent(column::setPrecision); + + Optional.of(config.getScale()) + .filter(s -> s != -1) + .ifPresent(column::setScale); + + Optional.ofNullable(config.getSqlType()) + .filter(s -> !s.isEmpty()) + .ifPresent(column::setSqlType); + + Optional.ofNullable(mappedForm) + .filter(mf -> !mf.isUniqueWithinGroup()) + .ifPresent(mf -> column.setUnique(config.getUnique())); + }); } } diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ComponentPropertyBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ComponentPropertyBinder.java index f37a487239..8488382b4d 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ComponentPropertyBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ComponentPropertyBinder.java @@ -42,6 +42,7 @@ public class ComponentPropertyBinder { private final EnumTypeBinder enumTypeBinder; private final CollectionBinder collectionBinder; private final PropertyFromValueCreator propertyFromValueCreator; + private final SimpleValueBinder simpleValueBinder; private final ComponentBinder componentBinder; public ComponentPropertyBinder(MetadataBuildingContext metadataBuildingContext, @@ -52,7 +53,7 @@ public class ComponentPropertyBinder { CollectionBinder collectionBinder, PropertyFromValueCreator propertyFromValueCreator) { this(metadataBuildingContext, namingStrategy, mappingCacheHolder, collectionHolder, - enumTypeBinder, collectionBinder, propertyFromValueCreator, null); + enumTypeBinder, collectionBinder, propertyFromValueCreator, null, new SimpleValueBinder(namingStrategy)); } protected ComponentPropertyBinder(MetadataBuildingContext metadataBuildingContext, @@ -62,7 +63,8 @@ public class ComponentPropertyBinder { EnumTypeBinder enumTypeBinder, CollectionBinder collectionBinder, PropertyFromValueCreator propertyFromValueCreator, - ComponentBinder componentBinder) { + ComponentBinder componentBinder, + SimpleValueBinder simpleValueBinder) { this.metadataBuildingContext = metadataBuildingContext; this.namingStrategy = namingStrategy; this.mappingCacheHolder = mappingCacheHolder; @@ -71,6 +73,7 @@ public class ComponentPropertyBinder { this.collectionBinder = collectionBinder; this.propertyFromValueCreator = propertyFromValueCreator; this.componentBinder = componentBinder != null ? componentBinder : new ComponentBinder(mappingCacheHolder, this); + this.simpleValueBinder = simpleValueBinder; } protected ComponentPropertyBinder() { @@ -82,6 +85,7 @@ public class ComponentPropertyBinder { this.collectionBinder = null; this.propertyFromValueCreator = null; this.componentBinder = null; + this.simpleValueBinder = null; } public void bindComponentProperty(Component component, PersistentProperty componentProperty, @@ -132,7 +136,7 @@ public class ComponentPropertyBinder { } else { // set type - new SimpleValueBinder(namingStrategy).bindSimpleValue((GrailsHibernatePersistentProperty) currentGrailsProp, componentProperty, (SimpleValue) value, path); + this.simpleValueBinder.bindSimpleValue((GrailsHibernatePersistentProperty) currentGrailsProp, (GrailsHibernatePersistentProperty) componentProperty, (SimpleValue) value, path); } } @@ -151,4 +155,4 @@ public class ComponentPropertyBinder { boolean isNullable, @Nonnull InFlightMetadataCollector mappings, String sessionFactoryBeanName) { componentBinder.bindComponent(component, property, isNullable, mappings, sessionFactoryBeanName); } -} +} \ No newline at end of file diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinder.java index 7aec0499ba..63ce20cd9a 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinder.java @@ -83,12 +83,12 @@ public class ManyToOneBinder { pc.setJoinTable(jt); } // set type - simpleValueBinder.bindSimpleValue(property, null, manyToOne, path); + simpleValueBinder.bindSimpleValue((GrailsHibernatePersistentProperty) property, null, manyToOne, path); } else { // bind column // set type - simpleValueBinder.bindSimpleValue(property, null, manyToOne, path); + simpleValueBinder.bindSimpleValue((GrailsHibernatePersistentProperty) property, null, manyToOne, path); } } diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/OneToOneBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/OneToOneBinder.java index 5413218dde..1a06c14b97 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/OneToOneBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/OneToOneBinder.java @@ -49,7 +49,7 @@ public class OneToOneBinder { oneToOne.setReferenceToPrimaryKey(false); if (hasOne || otherSide == null) { - simpleValueBinder.bindSimpleValue(property, null, oneToOne, path); + simpleValueBinder.bindSimpleValue((GrailsHibernatePersistentProperty) property, null, oneToOne, path); } else { oneToOne.setReferencedPropertyName(otherSide.getName()); diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleIdBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleIdBinder.java index f3960c09ec..0c761eca73 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleIdBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleIdBinder.java @@ -9,6 +9,7 @@ import org.hibernate.mapping.RootClass; import org.hibernate.mapping.Table; import org.grails.datastore.mapping.model.PersistentProperty; +import org.grails.orm.hibernate.cfg.GrailsHibernatePersistentProperty; import org.grails.orm.hibernate.cfg.GrailsHibernatePersistentEntity; import org.grails.orm.hibernate.cfg.Identity; import org.grails.orm.hibernate.cfg.Mapping; @@ -65,7 +66,7 @@ public class SimpleIdBinder { entity.setDeclaredIdentifierProperty(idProperty); entity.setIdentifier(id); // set type - simpleValueBinder.bindSimpleValue(identifier, null, id, EMPTY_PATH); + simpleValueBinder.bindSimpleValue((GrailsHibernatePersistentProperty) identifier, null, id, EMPTY_PATH); // create property Property prop = new Property(); diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinder.java index 3e11b57e7c..f7e289a4fd 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinder.java @@ -14,6 +14,7 @@ import org.hibernate.mapping.Table; import org.grails.datastore.mapping.model.PersistentProperty; import org.grails.datastore.mapping.model.types.TenantId; +import org.grails.orm.hibernate.cfg.ColumnConfig; import org.grails.orm.hibernate.cfg.GrailsHibernatePersistentEntity; import org.grails.orm.hibernate.cfg.GrailsHibernatePersistentProperty; import org.grails.orm.hibernate.cfg.Mapping; @@ -58,30 +59,23 @@ public class SimpleValueBinder { } public void bindSimpleValue( - @jakarta.annotation.Nonnull PersistentProperty property, - PersistentProperty parentProperty, + @jakarta.annotation.Nonnull GrailsHibernatePersistentProperty property, + GrailsHibernatePersistentProperty parentProperty, SimpleValue simpleValue, - String path) { - bindSimpleValue(property, property, parentProperty, simpleValue, path); - } - - public void bindSimpleValue( - @jakarta.annotation.Nonnull PersistentProperty property, - @jakarta.annotation.Nonnull PersistentProperty typeProperty, - PersistentProperty parentProperty, - SimpleValue simpleValue, - String path) { + String path, + GrailsHibernatePersistentProperty... typeProperty) { - PropertyConfig propertyConfig = ((GrailsHibernatePersistentProperty) property).getMappedForm(); + final GrailsHibernatePersistentProperty actualTypeProperty = (typeProperty.length > 0 && typeProperty[0] != null) ? typeProperty[0] : property; + PropertyConfig propertyConfig = property.getMappedForm(); Mapping mapping = null; if (property.getOwner() instanceof GrailsHibernatePersistentEntity persistentEntity) { mapping = persistentEntity.getMappedForm(); } - final String typeName = typeProperty instanceof GrailsHibernatePersistentProperty ghpp ? ghpp.getTypeName() : null; + final String typeName = actualTypeProperty.getTypeName(); if (typeName == null) { - if (!(typeProperty instanceof org.grails.datastore.mapping.model.types.Association)) { - Class<?> type = typeProperty.getType(); + if (!(actualTypeProperty instanceof org.grails.datastore.mapping.model.types.Association)) { + Class<?> type = actualTypeProperty.getType(); if (type != null) { simpleValue.setTypeName(type.getName()); } @@ -127,11 +121,11 @@ public class SimpleValueBinder { Optional.ofNullable(propertyConfig.getColumns()) .filter(list -> !list.isEmpty()) - .orElse(new ArrayList<>()) + .orElse(java.util.Arrays.asList(new ColumnConfig[]{null})) .forEach(cc -> { Column column = new Column(); columnConfigToColumnBinder.bindColumnConfigToColumn(column, cc, propertyConfig); - columnBinder.bindColumn((GrailsHibernatePersistentProperty) property, (GrailsHibernatePersistentProperty) parentProperty, column, cc, path, table); + columnBinder.bindColumn(property, parentProperty, column, cc, path, table); if (simpleValue instanceof DependantValue) { column.setNullable(true); } diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/VersionBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/VersionBinder.java index 3fe5964e25..896ceea8e5 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/VersionBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/VersionBinder.java @@ -8,6 +8,7 @@ import org.hibernate.mapping.RootClass; import org.hibernate.mapping.Table; import org.grails.datastore.mapping.model.PersistentProperty; +import org.grails.orm.hibernate.cfg.GrailsHibernatePersistentProperty; import org.grails.orm.hibernate.cfg.PersistentEntityNamingStrategy; import java.util.function.BiFunction; @@ -45,7 +46,7 @@ public class VersionBinder { BasicValue val = basicValueFactory.apply(metadataBuildingContext, entity.getTable()); // set type - simpleValueBinder.bindSimpleValue(version, null, val, EMPTY_PATH); + simpleValueBinder.bindSimpleValue((GrailsHibernatePersistentProperty) version, null, val, EMPTY_PATH); if (!val.isTypeSpecified()) { val.setTypeName("version".equals(version.getName()) ? "integer" : "timestamp"); diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionSecondPassBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionSecondPassBinder.java index 5a5d7fc95c..f55d2a1933 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionSecondPassBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/CollectionSecondPassBinder.java @@ -389,9 +389,9 @@ public class CollectionSecondPassBinder { // set type GrailsHibernatePersistentProperty identity = (GrailsHibernatePersistentProperty) refDomainClass.getIdentity(); if (identity != null) { - new SimpleValueBinder(namingStrategy).bindSimpleValue(property, identity, null, key, EMPTY_PATH); + new SimpleValueBinder(namingStrategy).bindSimpleValue((GrailsHibernatePersistentProperty) property, null, key, EMPTY_PATH, identity); } else { - new SimpleValueBinder(namingStrategy).bindSimpleValue(property, null, key, EMPTY_PATH); + new SimpleValueBinder(namingStrategy).bindSimpleValue((GrailsHibernatePersistentProperty) property, null, key, EMPTY_PATH); } } } diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ComponentPropertyBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ComponentPropertyBinderSpec.groovy index 31ca4f248e..ad5f43154e 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ComponentPropertyBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ComponentPropertyBinderSpec.groovy @@ -50,6 +50,8 @@ class ComponentPropertyBinderSpec extends HibernateGormDatastoreSpec { @Subject ComponentPropertyBinder binder + def mockSimpleValueBinder = Mock(SimpleValueBinder) // Mock SimpleValueBinder + def setup() { binder = new ComponentPropertyBinder( getGrailsDomainBinder().getMetadataBuildingContext(), @@ -59,13 +61,17 @@ class ComponentPropertyBinderSpec extends HibernateGormDatastoreSpec { enumTypeBinder, collectionBinder, propertyFromValueCreator, - componentBinder + componentBinder, + mockSimpleValueBinder ) } private void setupProperty(PersistentProperty prop, String name, Mapping mapping, PersistentEntity owner) { prop.getName() >> name - prop.getOwner() >> owner + _ * prop.getOwner() >> owner + if (prop instanceof GrailsHibernatePersistentProperty) { + _ * prop.getHibernateOwner() >> owner + } def config = new PropertyConfig() mapping.getColumns().put(name, config) prop.getMappedForm() >> config @@ -79,7 +85,11 @@ class ComponentPropertyBinderSpec extends HibernateGormDatastoreSpec { def table = new Table("my_table") def ownerEntity = Mock(GrailsHibernatePersistentEntity) ownerEntity.isRoot() >> true + def currentGrailsProp = Mock(GrailsHibernatePersistentProperty) + _ * currentGrailsProp.getOwner() >> ownerEntity + _ * currentGrailsProp.getHibernateOwner() >> ownerEntity + def componentProperty = Mock(GrailsHibernatePersistentProperty) def mappings = Mock(InFlightMetadataCollector) def hibernateProperty = new Property() @@ -87,7 +97,6 @@ class ComponentPropertyBinderSpec extends HibernateGormDatastoreSpec { def mapping = new Mapping() ownerEntity.getMappedForm() >> mapping - currentGrailsProp.getOwner() >> ownerEntity currentGrailsProp.getType() >> String setupProperty(currentGrailsProp, "street", mapping, ownerEntity) @@ -97,7 +106,7 @@ class ComponentPropertyBinderSpec extends HibernateGormDatastoreSpec { binder.bindComponentProperty(component, componentProperty, currentGrailsProp, root, "address", table, mappings, "sessionFactory") then: - 1 * propertyFromValueCreator.createProperty(_ as BasicValue, currentGrailsProp) >> hibernateProperty + 1 * mockSimpleValueBinder.bindSimpleValue(currentGrailsProp, componentProperty, _ as BasicValue, "address", _) component.getProperty("street") == hibernateProperty } @@ -117,8 +126,13 @@ class ComponentPropertyBinderSpec extends HibernateGormDatastoreSpec { def mapping = new Mapping() ownerEntity.getMappedForm() >> mapping - currentGrailsProp.getOwner() >> ownerEntity - currentGrailsProp.getAssociatedEntity() >> Mock(GrailsHibernatePersistentEntity) { getName() >> "Owner" } + _ * currentGrailsProp.getOwner() >> ownerEntity + _ * currentGrailsProp.getHibernateOwner() >> ownerEntity + currentGrailsProp.getAssociatedEntity() >> Mock(GrailsHibernatePersistentEntity) { + getName() >> "Owner" + getMappedForm() >> new Mapping() + isRoot() >> true + } currentGrailsProp.getType() >> Object setupProperty(currentGrailsProp, "owner", mapping, ownerEntity) @@ -148,10 +162,14 @@ class ComponentPropertyBinderSpec extends HibernateGormDatastoreSpec { def mapping = new Mapping() ownerEntity.getMappedForm() >> mapping - currentGrailsProp.getOwner() >> ownerEntity + _ * currentGrailsProp.getOwner() >> ownerEntity + _ * currentGrailsProp.getHibernateOwner() >> ownerEntity ((Association)currentGrailsProp).getInverseSide() >> Mock(Association) { isHasOne() >> false - getOwner() >> Mock(GrailsHibernatePersistentEntity) { getName() >> "Other" } + getOwner() >> Mock(GrailsHibernatePersistentEntity) { + getName() >> "Other" + isRoot() >> true + } getName() >> "other" } currentGrailsProp.getType() >> Object @@ -184,7 +202,8 @@ class ComponentPropertyBinderSpec extends HibernateGormDatastoreSpec { def mapping = new Mapping() ownerEntity.getMappedForm() >> mapping - currentGrailsProp.getOwner() >> ownerEntity + _ * currentGrailsProp.getOwner() >> ownerEntity + _ * currentGrailsProp.getHibernateOwner() >> ownerEntity currentGrailsProp.getType() >> MyEnum setupProperty(currentGrailsProp, "type", mapping, ownerEntity) @@ -210,31 +229,36 @@ class ComponentPropertyBinderSpec extends HibernateGormDatastoreSpec { def currentGrailsProp = Mock(GrailsHibernatePersistentProperty) def componentProperty = Mock(GrailsHibernatePersistentProperty) def ownerEntityGHPE = Mock(GrailsHibernatePersistentEntity) + ownerEntityGHPE.isRoot() >> true def mappings = Mock(InFlightMetadataCollector) def hibernateProperty = new Property() hibernateProperty.setName("street") - def value = new BasicValue(metadataBuildingContext, table) - def column = new Column("col1") - value.addColumn(column) - + def mapping = new Mapping() ownerEntityGHPE.getMappedForm() >> mapping - currentGrailsProp.getOwner() >> ownerEntityGHPE + _ * currentGrailsProp.getOwner() >> ownerEntityGHPE + _ * currentGrailsProp.getHibernateOwner() >> ownerEntityGHPE currentGrailsProp.getType() >> String setupProperty(currentGrailsProp, "street", mapping, ownerEntityGHPE) - componentProperty.getOwner() >> ownerEntity + componentProperty.getOwner() >> ownerEntity ownerEntity.isComponentPropertyNullable(componentProperty) >> true - propertyFromValueCreator.createProperty(value, currentGrailsProp) >> hibernateProperty - hibernateProperty.setValue(value) + propertyFromValueCreator.createProperty(_ as BasicValue, currentGrailsProp) >> hibernateProperty when: binder.bindComponentProperty(component, componentProperty, currentGrailsProp, root, "address", table, mappings, "sessionFactory") then: - column.isNullable() + 1 * mockSimpleValueBinder.bindSimpleValue( + currentGrailsProp, + componentProperty, + _ as BasicValue, + "address", + _ + ) + 1 * ownerEntity.isComponentPropertyNullable(componentProperty) >> true } enum MyEnum { VAL } -} \ No newline at end of file +} diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CompositeIdentifierToManyToOneBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CompositeIdentifierToManyToOneBinderSpec.groovy index 5016f46d5b..b0bd23b9d3 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CompositeIdentifierToManyToOneBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/CompositeIdentifierToManyToOneBinderSpec.groovy @@ -76,7 +76,7 @@ class CompositeIdentifierToManyToOneBinderSpec extends Specification { finalColumns[1].getName() == "ref_table_nested_entity_col_part_b_col" and: // 6. Verify the call to the simple value binder - 1 * simpleValueBinder.bindSimpleValue(association as PersistentProperty, null, value, path) + 1 * simpleValueBinder.bindSimpleValue(association as GrailsHibernatePersistentProperty, null, value, path) } def "Test bindCompositeIdentifierToManyToOne when column count matches"() { @@ -119,6 +119,6 @@ class CompositeIdentifierToManyToOneBinderSpec extends Specification { 0 * backticksRemover._ and: // 5. Verify the simple value binder is still called - 1 * simpleValueBinder.bindSimpleValue(association as PersistentProperty, null, value, path) + 1 * simpleValueBinder.bindSimpleValue(association as GrailsHibernatePersistentProperty, null, value, path) } } diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinderSpec.groovy index 3fd3863f82..661349c7ea 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/ManyToOneBinderSpec.groovy @@ -48,7 +48,7 @@ class ManyToOneBinderSpec extends HibernateGormDatastoreSpec { then: 1 * manyToOneValuesBinder.bindManyToOneValues(association as Association, manyToOne) compositeBinderCalls * compositeBinder.bindCompositeIdentifierToManyToOne(association as Association, manyToOne, _, refDomainClass, path) - simpleValueBinderCalls * simpleValueBinder.bindSimpleValue(association as PersistentProperty, null, manyToOne, path) + simpleValueBinderCalls * simpleValueBinder.bindSimpleValue(association as GrailsHibernatePersistentProperty, null, manyToOne, path) where: scenario | hasCompositeId | compositeBinderCalls | simpleValueBinderCalls @@ -86,7 +86,7 @@ class ManyToOneBinderSpec extends HibernateGormDatastoreSpec { then: 1 * manyToOneValuesBinder.bindManyToOneValues(property as Association, manyToOne) - 1 * simpleValueBinder.bindSimpleValue(property as PersistentProperty, null, manyToOne, "/test") + 1 * simpleValueBinder.bindSimpleValue(property as GrailsHibernatePersistentProperty, null, manyToOne, "/test") def resultConfig = mapping.getColumns().get("myCircularProp") resultConfig != null resultConfig.getJoinTable().getKey().getName() == "my_circular_prop_id" diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleIdBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleIdBinderSpec.groovy index 9eed3c6014..dfe5cf0d4b 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleIdBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleIdBinderSpec.groovy @@ -61,7 +61,7 @@ class SimpleIdBinderSpec extends HibernateGormDatastoreSpec { simpleIdBinder.bindSimpleId(testProperty, rootClass, new Identity(generator: GrailsSequenceGeneratorEnum.IDENTITY.toString())) then: - 1 * simpleValueBinder.bindSimpleValue(testProperty, null, _, "") + 1 * simpleValueBinder.bindSimpleValue(testProperty as GrailsHibernatePersistentProperty, null, _, "") 1 * propertyBinder.bindProperty(testProperty, _) rootClass.identifier instanceof BasicValue @@ -89,7 +89,7 @@ class SimpleIdBinderSpec extends HibernateGormDatastoreSpec { simpleIdBinder.bindSimpleId(testProperty, rootClass, new Identity(generator: GrailsSequenceGeneratorEnum.SEQUENCE.toString(), params: [sequence: 'SEQ_TEST'])) then: - 1 * simpleValueBinder.bindSimpleValue(testProperty, null, _, "") + 1 * simpleValueBinder.bindSimpleValue(testProperty as GrailsHibernatePersistentProperty, null, _, "") 1 * propertyBinder.bindProperty(testProperty, _) rootClass.identifier instanceof BasicValue diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinderSpec.groovy index c58ab6ddce..8b738dae52 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/SimpleValueBinderSpec.groovy @@ -128,7 +128,7 @@ class SimpleValueBinderSpec extends Specification { 0 * columnBinder.bindColumn(_, _, _, _, _, _) when: - binder.bindSimpleValue(tenantProp as PersistentProperty, null, sv2, null) + binder.bindSimpleValue(tenantProp, null, sv2, null) then: 0 * sv2.addFormula(_) diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/VersionBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/VersionBinderSpec.groovy index c9137a57db..e5deb84c96 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/VersionBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/VersionBinderSpec.groovy @@ -2,6 +2,7 @@ package org.grails.orm.hibernate.cfg.domainbinding import grails.gorm.specs.HibernateGormDatastoreSpec import org.grails.datastore.mapping.model.PersistentProperty +import org.grails.orm.hibernate.cfg.GrailsHibernatePersistentProperty import org.hibernate.boot.spi.MetadataBuildingContext import org.hibernate.engine.OptimisticLockStyle import org.hibernate.mapping.BasicValue @@ -32,7 +33,7 @@ class VersionBinderSpec extends HibernateGormDatastoreSpec { def table = new Table("TEST_TABLE") rootClass.setTable(table) - def versionProperty = Mock(PersistentProperty) { + def versionProperty = Mock(PersistentProperty, additionalInterfaces: [GrailsHibernatePersistentProperty]) { getName() >> "version" } @@ -43,7 +44,7 @@ class VersionBinderSpec extends HibernateGormDatastoreSpec { then: 1 * basicValueFactory.apply(metadataBuildingContext, table) >> basicValue - 1 * simpleValueBinder.bindSimpleValue(versionProperty, null, basicValue, "") + 1 * simpleValueBinder.bindSimpleValue(versionProperty, null, basicValue, "", _) 1 * propertyBinder.bindProperty(versionProperty, _) rootClass.getVersion() != null @@ -71,7 +72,7 @@ class VersionBinderSpec extends HibernateGormDatastoreSpec { def table = new Table("TEST_TABLE") rootClass.setTable(table) - def versionProperty = Mock(PersistentProperty) { + def versionProperty = Mock(PersistentProperty, additionalInterfaces: [GrailsHibernatePersistentProperty]) { getName() >> "lastUpdated" } @@ -84,4 +85,4 @@ class VersionBinderSpec extends HibernateGormDatastoreSpec { 1 * basicValueFactory.apply(metadataBuildingContext, table) >> basicValue basicValue.getTypeName() == "timestamp" } -} +} \ No newline at end of file
