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 d7f129f9740c94bccb882e5577f49b61e9eea111 Author: Walter Duque de Estrada <[email protected]> AuthorDate: Sat Mar 14 16:34:48 2026 -0500 hibernate 7: Refactoring signature of EnumTypeBinder --- .../hibernate/cfg/domainbinding/binder/EnumTypeBinder.java | 9 +++++++-- .../secondpass/BasicCollectionElementBinder.java | 4 +--- .../secondpass/CollectionSecondPassBinder.java | 4 ++-- .../hibernate/cfg/domainbinding/EnumTypeBinderSpec.groovy | 14 +++++++------- .../secondpass/BasicCollectionElementBinderSpec.groovy | 4 ++-- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/EnumTypeBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/EnumTypeBinder.java index 9421552c68..f933ca6451 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/EnumTypeBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/EnumTypeBinder.java @@ -71,13 +71,18 @@ public class EnumTypeBinder { public BasicValue bindEnumType( @Nonnull HibernatePersistentProperty property, Class<?> propertyType, Table table, String path) { - BasicValue simpleValue = new BasicValue(metadataBuildingContext, table); String columnName = columnNameForPropertyAndPathFetcher.getColumnNameForPropertyAndPath(property, path, null); + return bindEnumTypeForColumn(property, propertyType, table, columnName); + } + + public BasicValue bindEnumTypeForColumn( + @Nonnull HibernatePersistentProperty property, Class<?> propertyType, Table table, @Nonnull String columnName) { + BasicValue simpleValue = new BasicValue(metadataBuildingContext, table); bindEnumType(property, propertyType, simpleValue, columnName); return simpleValue; } - public void bindEnumType( + protected void bindEnumType( HibernatePersistentProperty property, Class<?> propertyType, BasicValue simpleValue, String columnName) { PropertyConfig pc = property.getMappedForm(); Properties enumProperties = new Properties(); diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/BasicCollectionElementBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/BasicCollectionElementBinder.java index fcfe85211f..cc8143689e 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/BasicCollectionElementBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/BasicCollectionElementBinder.java @@ -80,9 +80,7 @@ public class BasicCollectionElementBinder { : new BackticksRemover().apply(prop) + UNDERSCORE + new BackticksRemover().apply(clazz); } if (isEnum) { - BasicValue element = new BasicValue(metadataBuildingContext, collection.getCollectionTable()); - enumTypeBinder.bindEnumType(property, referencedType, element, columnName); - return element; + return enumTypeBinder.bindEnumTypeForColumn(property, referencedType, collection.getCollectionTable(), columnName); } else { String typeName = property.getTypeName(referencedType); BasicValue element = simpleValueColumnBinder.bindSimpleValue( 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 95033c2820..cb0e360ecb 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 @@ -82,7 +82,7 @@ public class CollectionSecondPassBinder { collectionKeyColumnUpdater.bind(property, associatedClass, collection); collection.setCacheConcurrencyStrategy(property.getCacheUsage()); - bindCollectionElement(property, mappings, collection); + bindCollectionElement(property, collection); } private void bindOneToManyAssociation( @@ -99,7 +99,7 @@ public class CollectionSecondPassBinder { } private void bindCollectionElement( - HibernateToManyProperty property, InFlightMetadataCollector mappings, Collection collection) { + HibernateToManyProperty property, Collection collection) { if (property instanceof HibernateManyToManyProperty manyToMany && manyToMany.isBidirectional()) { manyToManyElementBinder.bind(manyToMany, collection); } else if (property.isBidirectionalOneToManyMap() && property.isBidirectional()) { diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/EnumTypeBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/EnumTypeBinderSpec.groovy index 1e7a56db7c..037a67579c 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/EnumTypeBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/EnumTypeBinderSpec.groovy @@ -55,10 +55,9 @@ class EnumTypeBinderSpec extends HibernateGormDatastoreSpec { def owner = createPersistentEntity(clazz, grailsDomainBinder) PersistentProperty property = owner.getPropertyByName("status") def table = new Table("person") - def simpleValue = new BasicValue(grailsDomainBinder.metadataBuildingContext, table) when: "the enum is bound" - binder.bindEnumType(property, Status01, simpleValue, "status_col") + def simpleValue = binder.bindEnumTypeForColumn(property as HibernatePersistentProperty, Status01, table, "status_col") then: "the correct hibernate type is set" simpleValue.getTypeName() == expectedHibernateType @@ -87,10 +86,9 @@ class EnumTypeBinderSpec extends HibernateGormDatastoreSpec { def owner = createPersistentEntity( clazz, grailsDomainBinder) PersistentProperty property = owner.getPropertyByName("status") def table = new Table("person") - def simpleValue = new BasicValue(grailsDomainBinder.metadataBuildingContext, table) def columnName = "status_col" when: "the enum is bound" - binder.bindEnumType(property, Status01, simpleValue, columnName) + def simpleValue = binder.bindEnumTypeForColumn(property as HibernatePersistentProperty, Status01, table, columnName) then: table.columns.size() == 1 @@ -118,11 +116,10 @@ class EnumTypeBinderSpec extends HibernateGormDatastoreSpec { def owner = createPersistentEntity(clazz, grailsDomainBinder) PersistentProperty property = owner.getPropertyByName("status") def table = new Table("person") - def simpleValue = new BasicValue(grailsDomainBinder.metadataBuildingContext, table) def columnName = "status_col" when: "the enum is bound" - binder.bindEnumType(property, Status01, simpleValue, columnName) + binder.bindEnumTypeForColumn(property as HibernatePersistentProperty, Status01, table, columnName) then: "the index and column binders are invoked the correct number of times" times * indexBinder.bindIndex(columnName, _ as Column, _, table) @@ -137,9 +134,12 @@ class EnumTypeBinderSpec extends HibernateGormDatastoreSpec { def "should create BasicValue and bind enum type"() { given: "A root entity and its enum property" def grailsDomainBinder = getGrailsDomainBinder() - def owner = createPersistentEntity(Person01, grailsDomainBinder) + def owner = createPersistentEntity(Person01, grailsDomainBinder) as org.grails.orm.hibernate.cfg.domainbinding.hibernate.GrailsHibernatePersistentEntity PersistentProperty property = owner.getPropertyByName("status") def table = new Table("person") + def rootClass = new org.hibernate.mapping.RootClass(grailsDomainBinder.getMetadataBuildingContext()) + rootClass.setTable(table) + owner.setPersistentClass(rootClass) when: "the enum is bound using the new signature" def result = binder.bindEnumType(property as HibernatePersistentProperty, Status01, table, "") diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/BasicCollectionElementBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/BasicCollectionElementBinderSpec.groovy index d623ed7c61..8ea3cb4822 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/BasicCollectionElementBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/secondpass/BasicCollectionElementBinderSpec.groovy @@ -53,7 +53,7 @@ class BasicCollectionElementBinderSpec extends HibernateGormDatastoreSpec { then: element != null element.getColumnSpan() > 0 - 0 * enumTypeBinder.bindEnumType(*_) + 0 * enumTypeBinder._ } void "bind delegates to enumTypeBinder for enum collection"() { @@ -67,7 +67,7 @@ class BasicCollectionElementBinderSpec extends HibernateGormDatastoreSpec { then: element != null - 1 * enumTypeBinder.bindEnumType(property, BCEBStatus, _ as BasicValue, _) + 1 * enumTypeBinder.bindEnumTypeForColumn(property, BCEBStatus, collection.getCollectionTable(), _) >> Mock(BasicValue) } }
