This is an automated email from the ASF dual-hosted git repository.

borinquenkid pushed a commit to branch feat/gorm-registry-core
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 5c0add539935f31be4982a3646d0c74b50be3658
Author: Walter Duque de Estrada <[email protected]>
AuthorDate: Fri Jun 26 22:42:27 2026 -0500

    fix: restore registerConstraints to GormEnhancer dropped in scaling refactor
    
    HibernateGormEnhancer (H5 and H7) both declare @Override registerConstraints
    as a no-op. The scaling commit's GormEnhancer refactor omitted this 
protected
    hook method, making the @Override annotation invalid and causing a Java stub
    compilation error: "method does not override or implement a method from a
    supertype".
    
    Restores the original implementation (loads ConstraintRegistrar via 
reflection
    if present) and calls it from the constructor, consistent with the 
pre-scaling
    behaviour.
    
    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
---
 .../groovy/org/grails/datastore/gorm/GormEnhancer.groovy | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git 
a/grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/GormEnhancer.groovy
 
b/grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/GormEnhancer.groovy
index 3d603155ba..5743fe3b60 100644
--- 
a/grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/GormEnhancer.groovy
+++ 
b/grails-datamapping-core/src/main/groovy/org/grails/datastore/gorm/GormEnhancer.groovy
@@ -25,6 +25,7 @@ import org.slf4j.Logger
 import org.slf4j.LoggerFactory
 
 import org.springframework.transaction.PlatformTransactionManager
+import org.springframework.util.ClassUtils
 
 import grails.gorm.MultiTenant
 import org.grails.datastore.gorm.finders.FinderMethod
@@ -97,6 +98,8 @@ class GormEnhancer implements Closeable {
         String qualifier = 
ConnectionSourceNameResolver.resolveDefaultConnectionSourceName(datastore)
         registry.initializeDatastore(datastore, qualifier)
 
+        registerConstraints(datastore)
+
         for (entity in datastore.mappingContext.persistentEntities) {
             registerEntity(entity)
         }
@@ -297,6 +300,19 @@ class GormEnhancer implements Closeable {
         }
     }
 
+    @CompileDynamic
+    protected void registerConstraints(Datastore datastore) {
+        try {
+            String className = 
'org.grails.datastore.gorm.support.ConstraintRegistrar'
+            ClassLoader classLoader = getClass().getClassLoader()
+            if (ClassUtils.isPresent(className, classLoader)) {
+                classLoader.loadClass(className).newInstance(datastore)
+            }
+        } catch (Throwable e) {
+            log.debug("Unable to register GORM constraints. Not running a 
Grails environment. This can be safely ignored if you are not running Grails: 
$e.message", e)
+        }
+    }
+
     @CompileDynamic
     protected void addStaticMethods(PersistentEntity e) {
         def cls = e.javaClass

Reply via email to