You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by bo...@apache.org on 2026/06/27 16:35:33 UTC
(grails-core) 02/07: fix: restore registerConstraints to GormEnhancer dropped in scaling refactor
This is an automated email from the ASF dual-hosted git repository.
borinquenkid pushed a commit to branch feat/gorm-registry-core-impl
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit fd1898e11ea3681bda81df6800f7a707b21ecddf
Author: Walter Duque de Estrada <wb...@mac.com>
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 <no...@anthropic.com>
---
.../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 a8cbd4f690..67f840dc6b 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.mapping.core.Datastore
@@ -90,6 +91,8 @@ class GormEnhancer implements Closeable {
String qualifier = ConnectionSourceNameResolver.resolveDefaultConnectionSourceName(datastore)
registry.initializeDatastore(datastore, qualifier)
+ registerConstraints(datastore)
+
for (entity in datastore.mappingContext.persistentEntities) {
registerEntity(entity)
}
@@ -219,6 +222,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