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 19c8b9bdf2d71b8285cb764dbb88fe55cce44891
Author: Walter Duque de Estrada <[email protected]>
AuthorDate: Wed Mar 4 16:58:38 2026 -0600

    refactor(hibernate7): type safety, API modernisation, and spec coverage
---
 .../cfg/domainbinding/binder/CollectionBinder.java       |   2 --
 .../hibernate/cfg/domainbinding/binder/ColumnBinder.java |   6 +-----
 .../connections/HibernateConnectionSourceFactory.java    |  12 +++++++-----
 .../compiler/HibernateEntityTransformationSpec.groovy    |   2 ++
 org/hibernate/engine/spi/ManagedEntity.class             | Bin 0 -> 1528 bytes
 .../engine/spi/PersistentAttributeInterceptable.class    | Bin 0 -> 707 bytes
 .../engine/spi/PersistentAttributeInterceptor.class      | Bin 0 -> 2373 bytes
 7 files changed, 10 insertions(+), 12 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 adea9b6d82..114e01ec05 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
@@ -18,7 +18,6 @@
  */
 package org.grails.orm.hibernate.cfg.domainbinding.binder;
 
-import jakarta.annotation.Nonnull;
 import org.grails.orm.hibernate.cfg.GrailsHibernateUtil;
 import org.grails.orm.hibernate.cfg.JoinTable;
 import org.grails.orm.hibernate.cfg.PersistentEntityNamingStrategy;
@@ -67,7 +66,6 @@ import org.slf4j.LoggerFactory;
 @SuppressWarnings("PMD.DataflowAnomalyAnalysis")
 public class CollectionBinder {
 
-  private static final Logger LOG = 
LoggerFactory.getLogger(CollectionBinder.class);
 
   private final MetadataBuildingContext metadataBuildingContext;
   private final PersistentEntityNamingStrategy namingStrategy;
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/ColumnBinder.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/ColumnBinder.java
index b68a726b51..d08d1b92a4 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/ColumnBinder.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/cfg/domainbinding/binder/ColumnBinder.java
@@ -114,11 +114,7 @@ public class ColumnBinder {
       } else if (property instanceof HibernateOneToOneProperty
           && association.isBidirectional()
           && !association.isOwningSide()) {
-        if (association.getInverseSide().isHasOne()) {
-          column.setNullable(false);
-        } else {
-          column.setNullable(true);
-        }
+          column.setNullable(!association.getInverseSide().isHasOne());
       } else if ((property instanceof ToOne) && association.isCircular()) {
         column.setNullable(true);
       } else {
diff --git 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/connections/HibernateConnectionSourceFactory.java
 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/connections/HibernateConnectionSourceFactory.java
index 854acb3943..3e1fd89df3 100644
--- 
a/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/connections/HibernateConnectionSourceFactory.java
+++ 
b/grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/connections/HibernateConnectionSourceFactory.java
@@ -24,6 +24,9 @@ import java.io.Serializable;
 import java.util.Collections;
 import java.util.Map;
 import javax.sql.DataSource;
+
+import jakarta.annotation.Nullable;
+
 import 
org.grails.datastore.gorm.jdbc.connections.CachedDataSourceConnectionSourceFactory;
 import 
org.grails.datastore.gorm.jdbc.connections.DataSourceConnectionSourceFactory;
 import org.grails.datastore.gorm.jdbc.connections.DataSourceSettings;
@@ -40,7 +43,6 @@ import 
org.grails.orm.hibernate.cfg.HibernateMappingContextConfiguration;
 import org.grails.orm.hibernate.cfg.Settings;
 import org.grails.orm.hibernate.cfg.domainbinding.binder.GrailsDomainBinder;
 import org.grails.orm.hibernate.support.ClosureEventTriggeringInterceptor;
-import org.grails.orm.hibernate.support.ClosureEventTriggeringInterceptor;
 import org.hibernate.Interceptor;
 import org.hibernate.SessionFactory;
 import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
@@ -79,7 +81,7 @@ public class HibernateConnectionSourceFactory
       new CachedDataSourceConnectionSourceFactory();
 
   protected HibernateMappingContext mappingContext;
-  protected Class<?>[] persistentClasses = new Class<?>[0];
+  protected Class<?>[] persistentClasses;
   private ApplicationContext applicationContext;
   protected HibernateEventListeners hibernateEventListeners;
   protected Interceptor interceptor;
@@ -289,7 +291,7 @@ public class HibernateConnectionSourceFactory
       String qualified = Settings.SETTING_DATASOURCES + '.' + 
Settings.SETTING_DATASOURCE;
       HibernateConnectionSourceSettings settings =
           new HibernateConnectionSourceSettingsBuilder(configuration, "", 
fallbackSettings).build();
-      Map config = configuration.getProperty(qualified, Map.class, 
Collections.emptyMap());
+      var config = configuration.getProperty(qualified, Map.class, 
Collections.emptyMap());
       if (!config.isEmpty()) {
         DataSourceSettings dsFallback = 
extractDataSourceFallback(fallbackSettings);
         settings.setDataSource(
@@ -330,13 +332,13 @@ public class HibernateConnectionSourceFactory
   }
 
   @Override
-  public void setApplicationContext(ApplicationContext applicationContext) 
throws BeansException {
+  public void setApplicationContext(@Nullable  ApplicationContext 
applicationContext) throws BeansException {
     this.applicationContext = applicationContext;
     this.messageSource = applicationContext;
   }
 
   @Override
-  public void setMessageSource(MessageSource messageSource) {
+  public void setMessageSource(@Nullable MessageSource messageSource) {
     this.messageSource = messageSource;
   }
 }
diff --git 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/compiler/HibernateEntityTransformationSpec.groovy
 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/compiler/HibernateEntityTransformationSpec.groovy
index c5c6d681da..b3f75d993a 100644
--- 
a/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/compiler/HibernateEntityTransformationSpec.groovy
+++ 
b/grails-data-hibernate7/core/src/test/groovy/org/grails/orm/hibernate/compiler/HibernateEntityTransformationSpec.groovy
@@ -184,5 +184,7 @@ class MyEntity {
         
cls.getMethod('$$_hibernate_getNextManagedEntity').isAnnotationPresent(Generated)
         cls.getMethod('$$_hibernate_setPreviousManagedEntity', 
ManagedEntity).isAnnotationPresent(Generated)
         cls.getMethod('$$_hibernate_setNextManagedEntity', 
ManagedEntity).isAnnotationPresent(Generated)
+        
cls.getMethod('$$_hibernate_getInstanceId').isAnnotationPresent(Generated)
+        cls.getMethod('$$_hibernate_setInstanceId', 
int).isAnnotationPresent(Generated)
     }
 }
\ No newline at end of file
diff --git a/org/hibernate/engine/spi/ManagedEntity.class 
b/org/hibernate/engine/spi/ManagedEntity.class
new file mode 100644
index 0000000000..beb6247ca7
Binary files /dev/null and b/org/hibernate/engine/spi/ManagedEntity.class differ
diff --git a/org/hibernate/engine/spi/PersistentAttributeInterceptable.class 
b/org/hibernate/engine/spi/PersistentAttributeInterceptable.class
new file mode 100644
index 0000000000..e7ecf16f75
Binary files /dev/null and 
b/org/hibernate/engine/spi/PersistentAttributeInterceptable.class differ
diff --git a/org/hibernate/engine/spi/PersistentAttributeInterceptor.class 
b/org/hibernate/engine/spi/PersistentAttributeInterceptor.class
new file mode 100644
index 0000000000..9c1b81f203
Binary files /dev/null and 
b/org/hibernate/engine/spi/PersistentAttributeInterceptor.class differ

Reply via email to