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 949d0189543c344481704e68b8e3c306e43255b8 Author: Walter Duque de Estrada <[email protected]> AuthorDate: Fri Feb 13 15:10:09 2026 -0600 updated SimpleIdBinder.bindSimpleId to include Table as the last argument, which is now used to initialize BasicValueIdCreator. I also updated IdentityBinder and the relevant test specifications (SimpleIdBinderSpec and IdentityBinderSpec) to pass the table argument --- .../orm/hibernate/cfg/domainbinding/binder/IdentityBinder.java | 2 +- .../orm/hibernate/cfg/domainbinding/binder/SimpleIdBinder.java | 8 ++++---- .../orm/hibernate/cfg/domainbinding/IdentityBinderSpec.groovy | 8 ++++---- .../orm/hibernate/cfg/domainbinding/SimpleIdBinderSpec.groovy | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/IdentityBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/IdentityBinder.java index e6559afaa9..b6fa613399 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/IdentityBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/IdentityBinder.java @@ -46,7 +46,7 @@ public class IdentityBinder { if (identity != null && identity.getName() == null) { identity.setName(root.getEntityName()); } - simpleIdBinder.bindSimpleId(domainClass, root, identity); + simpleIdBinder.bindSimpleId(domainClass, root, identity, root.getTable()); } } } \ No newline at end of file diff --git a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/SimpleIdBinder.java b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/SimpleIdBinder.java index 71bb2c66a2..17137b288f 100644 --- a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/SimpleIdBinder.java +++ b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/SimpleIdBinder.java @@ -45,13 +45,13 @@ public class SimpleIdBinder { } - public void bindSimpleId(@Nonnull GrailsHibernatePersistentEntity domainClass, RootClass entity, Identity mappedId) { + public void bindSimpleId(@Nonnull GrailsHibernatePersistentEntity domainClass, RootClass entity, Identity mappedId, Table table) { Mapping result = domainClass.getMappedForm(); boolean useSequence = result != null && result.isTablePerConcreteClass(); // create the id value - BasicValueIdCreator idCreator = this.basicValueIdCreator != null ? this.basicValueIdCreator : new BasicValueIdCreator(metadataBuildingContext, jdbcEnvironment, entity.getTable()); + BasicValueIdCreator idCreator = this.basicValueIdCreator != null ? this.basicValueIdCreator : new BasicValueIdCreator(metadataBuildingContext, jdbcEnvironment, table); BasicValue id = idCreator.getBasicValueId(mappedId, domainClass, useSequence); var identifier = domainClass.getIdentity(); @@ -81,7 +81,7 @@ public class SimpleIdBinder { // set identifier property entity.setIdentifierProperty(prop); - Table table = id.getTable(); - table.setPrimaryKey(new PrimaryKey(table)); + Table pkTable = id.getTable(); + pkTable.setPrimaryKey(new PrimaryKey(pkTable)); } } diff --git a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/IdentityBinderSpec.groovy b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/IdentityBinderSpec.groovy index 86133b8ec1..34b95b3470 100644 --- a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/IdentityBinderSpec.groovy +++ b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/cfg/domainbinding/IdentityBinderSpec.groovy @@ -40,7 +40,7 @@ class IdentityBinderSpec extends HibernateGormDatastoreSpec { binder.bindIdentity(domainClass, root, mappings, null, "sessionFactory") then: - 1 * simpleIdBinder.bindSimpleId(domainClass, root, null) + 1 * simpleIdBinder.bindSimpleId(domainClass, root, null, _) } def "should delegate to compositeIdBinder when mapping is null and domainClass has composite identity"() { @@ -91,7 +91,7 @@ class IdentityBinderSpec extends HibernateGormDatastoreSpec { binder.bindIdentity(domainClass, root, mappings, gormMapping, "sessionFactory") then: - 1 * simpleIdBinder.bindSimpleId(domainClass, root, identity) + 1 * simpleIdBinder.bindSimpleId(domainClass, root, identity, _) } def "should not lookup property by name if identity name matches domain class name"() { @@ -110,7 +110,7 @@ class IdentityBinderSpec extends HibernateGormDatastoreSpec { binder.bindIdentity(domainClass, root, mappings, gormMapping, "sessionFactory") then: - 1 * simpleIdBinder.bindSimpleId(domainClass, root, identity) + 1 * simpleIdBinder.bindSimpleId(domainClass, root, identity, _) } def "should set entity name on identity if it is null"() { @@ -131,6 +131,6 @@ class IdentityBinderSpec extends HibernateGormDatastoreSpec { then: identity.getName() == "MyEntity" - 1 * simpleIdBinder.bindSimpleId(domainClass, root, identity) + 1 * simpleIdBinder.bindSimpleId(domainClass, root, identity, _) } } 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 30511a1f3c..5cc6b3115c 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 @@ -64,7 +64,7 @@ class SimpleIdBinderSpec extends HibernateGormDatastoreSpec { rootClass.setTable(currentTable) when: - simpleIdBinder.bindSimpleId(domainClass, rootClass, new Identity(generator: GrailsSequenceGeneratorEnum.IDENTITY.toString())) + simpleIdBinder.bindSimpleId(domainClass, rootClass, new Identity(generator: GrailsSequenceGeneratorEnum.IDENTITY.toString()), rootClass.getTable()) then: 1 * simpleValueBinder.bindSimpleValue(testProperty as GrailsHibernatePersistentProperty, null, _, "") @@ -94,7 +94,7 @@ class SimpleIdBinderSpec extends HibernateGormDatastoreSpec { rootClass.setTable(currentTable) when: - simpleIdBinder.bindSimpleId(domainClass, rootClass, new Identity(generator: GrailsSequenceGeneratorEnum.SEQUENCE.toString(), params: [sequence: 'SEQ_TEST'])) + simpleIdBinder.bindSimpleId(domainClass, rootClass, new Identity(generator: GrailsSequenceGeneratorEnum.SEQUENCE.toString(), params: [sequence: 'SEQ_TEST']), rootClass.getTable()) then: 1 * simpleValueBinder.bindSimpleValue(testProperty as GrailsHibernatePersistentProperty, null, _, "") @@ -116,7 +116,7 @@ class SimpleIdBinderSpec extends HibernateGormDatastoreSpec { def rootClass = new RootClass(metadataBuildingContext) when: - simpleIdBinder.bindSimpleId(domainClass, rootClass, new Identity(name: "nonExistent")) + simpleIdBinder.bindSimpleId(domainClass, rootClass, new Identity(name: "nonExistent"), rootClass.getTable()) then: thrown(org.hibernate.MappingException)
