xpusostomos opened a new issue, #14445:
URL: https://github.com/apache/grails-core/issues/14445

   Using Grails 4.0.1, hibernate5:7.0.0, hibernate-code:5.4.0
   
   I'm trying to save an object with no validation:
   
   ```groovy
   Name.withTransaction {
       nm.save(validate: false, deepValidate: false, flush: true)
   }
   ```
   
   However it ends up calling validation and crashing 
   
   ```
   doValidate:287, ClosureEventListener (org.grails.orm.hibernate.support)
   call:249, ClosureEventListener$7 (org.grails.orm.hibernate.support)
   call:238, ClosureEventListener$7 (org.grails.orm.hibernate.support)
   doWithManualSession:362, ClosureEventListener 
(org.grails.orm.hibernate.support)
   onPreUpdate:238, ClosureEventListener (org.grails.orm.hibernate.support)
   onPreUpdate:145, HibernateEventListener 
(org.grails.orm.hibernate.event.listener)
   onPersistenceEvent:66, HibernateEventListener 
(org.grails.orm.hibernate.event.listener)
   onApplicationEvent:51, AbstractPersistenceEventListener 
(org.grails.datastore.mapping.engine.event)
   doInvokeListener:172, SimpleApplicationEventMulticaster 
(org.springframework.context.event)
   invokeListener:165, SimpleApplicationEventMulticaster 
(org.springframework.context.event)
   multicastEvent:139, SimpleApplicationEventMulticaster 
(org.springframework.context.event)
   publishEvent:402, AbstractApplicationContext 
(org.springframework.context.support)
   publishEvent:359, AbstractApplicationContext 
(org.springframework.context.support)
   publishEvent:30, ConfigurableApplicationContextEventPublisher 
(org.grails.datastore.gorm.events)
   publishEvent:278, ClosureEventTriggeringInterceptor 
(org.grails.orm.hibernate.support)
   onPreUpdate:246, ClosureEventTriggeringInterceptor 
(org.grails.orm.hibernate.support)
   preUpdate:248, EntityUpdateAction (org.hibernate.action.internal)
   execute:119, EntityUpdateAction (org.hibernate.action.internal)
   executeActions:604, ActionQueue (org.hibernate.engine.spi)
   executeActions:478, ActionQueue (org.hibernate.engine.spi)
   performExecutions:356, AbstractFlushingEventListener 
(org.hibernate.event.internal)
   onFlush:39, DefaultFlushEventListener (org.hibernate.event.internal)
   doFlush:1457, SessionImpl (org.hibernate.internal)
   flush:1443, SessionImpl (org.hibernate.internal)
   call:-1, Session$flush (org.hibernate)
   defaultCall:47, CallSiteArray (org.codehaus.groovy.runtime.callsite)
   call:115, AbstractCallSite (org.codehaus.groovy.runtime.callsite)
   call:119, AbstractCallSite (org.codehaus.groovy.runtime.callsite)
   doCall:83, BackgroundThread$_processName_closure4 
(au.gov.environment.labelname)
   invoke0:-1, NativeMethodAccessorImpl (sun.reflect)
   invoke:62, NativeMethodAccessorImpl (sun.reflect)
   invoke:43, DelegatingMethodAccessorImpl (sun.reflect)
   invoke:498, Method (java.lang.reflect)
   invoke:101, CachedMethod (org.codehaus.groovy.reflection)
   doMethodInvoke:323, MetaMethod (groovy.lang)
   invokeMethod:263, ClosureMetaClass (org.codehaus.groovy.runtime.metaclass)
   invokeMethod:1041, MetaClassImpl (groovy.lang)
   call:405, Closure (groovy.lang)
   invokeCustom:50, ConvertedClosure (org.codehaus.groovy.runtime)
   invoke:122, ConversionHandler (org.codehaus.groovy.runtime)
   doInHibernate:-1, $Proxy124 (com.sun.proxy)
   doExecute:297, GrailsHibernateTemplate (org.grails.orm.hibernate)
   execute:241, GrailsHibernateTemplate (org.grails.orm.hibernate)
   execute:120, GrailsHibernateTemplate (org.grails.orm.hibernate)
   withSession:355, AbstractHibernateDatastore (org.grails.orm.hibernate)
   withSession:88, AbstractHibernateGormStaticApi (org.grails.orm.hibernate)
   withSession:917, GormEntity$Trait$Helper (org.grails.datastore.gorm)
   call:-1, GormEntity$Trait$Helper$withSession$6 (org.grails.datastore.gorm)
   defaultCall:47, CallSiteArray (org.codehaus.groovy.runtime.callsite)
   call:-1, GormEntity$Trait$Helper$withSession$6 (org.grails.datastore.gorm)
   withSession:-1, Name (au.gov.environment.labelname)
   call:-1, Name$withSession$3 (au.gov.environment.labelname)
   defaultCall:47, CallSiteArray (org.codehaus.groovy.runtime.callsite)
   call:115, AbstractCallSite (org.codehaus.groovy.runtime.callsite)
   call:127, AbstractCallSite (org.codehaus.groovy.runtime.callsite)
   processName:82, BackgroundThread (au.gov.environment.labelname)
   invoke0:-1, NativeMethodAccessorImpl (sun.reflect)
   invoke:62, NativeMethodAccessorImpl (sun.reflect)
   invoke:43, DelegatingMethodAccessorImpl (sun.reflect)
   invoke:498, Method (java.lang.reflect)
   invoke:101, CachedMethod (org.codehaus.groovy.reflection)
   doMethodInvoke:323, MetaMethod (groovy.lang)
   invokeMethod:351, ClosureMetaClass (org.codehaus.groovy.runtime.metaclass)
   callCurrent:64, PogoMetaClassSite (org.codehaus.groovy.runtime.callsite)
   defaultCallCurrent:51, CallSiteArray (org.codehaus.groovy.runtime.callsite)
   callCurrent:156, AbstractCallSite (org.codehaus.groovy.runtime.callsite)
   callCurrent:176, AbstractCallSite (org.codehaus.groovy.runtime.callsite)
   doCall:54, BackgroundThread$__tt__doWork_closure5$_closure6 
(au.gov.environment.labelname)
   invoke0:-1, NativeMethodAccessorImpl (sun.reflect)
   invoke:62, NativeMethodAccessorImpl (sun.reflect)
   invoke:43, DelegatingMethodAccessorImpl (sun.reflect)
   invoke:498, Method (java.lang.reflect)
   invoke:101, CachedMethod (org.codehaus.groovy.reflection)
   doMethodInvoke:323, MetaMethod (groovy.lang)
   invokeMethod:263, ClosureMetaClass (org.codehaus.groovy.runtime.metaclass)
   invokeMethod:1041, MetaClassImpl (groovy.lang)
   call:405, Closure (groovy.lang)
   call:421, Closure (groovy.lang)
   each:2296, DefaultGroovyMethods (org.codehaus.groovy.runtime)
   each:2281, DefaultGroovyMethods (org.codehaus.groovy.runtime)
   each:2322, DefaultGroovyMethods (org.codehaus.groovy.runtime)
   invoke:-1, dgm$186 (org.codehaus.groovy.runtime)
   invoke:244, PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce 
(org.codehaus.groovy.runtime.callsite)
   call:53, PojoMetaMethodSite (org.codehaus.groovy.runtime.callsite)
   defaultCall:47, CallSiteArray (org.codehaus.groovy.runtime.callsite)
   call:115, AbstractCallSite (org.codehaus.groovy.runtime.callsite)
   call:127, AbstractCallSite (org.codehaus.groovy.runtime.callsite)
   doCall:52, BackgroundThread$__tt__doWork_closure5 
(au.gov.environment.labelname)
   invoke0:-1, NativeMethodAccessorImpl (sun.reflect)
   invoke:62, NativeMethodAccessorImpl (sun.reflect)
   invoke:43, DelegatingMethodAccessorImpl (sun.reflect)
   invoke:498, Method (java.lang.reflect)
   invoke:101, CachedMethod (org.codehaus.groovy.reflection)
   doMethodInvoke:323, MetaMethod (groovy.lang)
   invokeMethod:263, ClosureMetaClass (org.codehaus.groovy.runtime.metaclass)
   invokeMethod:1041, MetaClassImpl (groovy.lang)
   call:405, Closure (groovy.lang)
   call:421, Closure (groovy.lang)
   doInTransaction:94, GrailsTransactionTemplate$2 (grails.gorm.transactions)
   execute:140, TransactionTemplate (org.springframework.transaction.support)
   execute:91, GrailsTransactionTemplate (grails.gorm.transactions)
   withTransaction:1014, GormStaticApi (org.grails.datastore.gorm)
   withTransaction:966, GormStaticApi (org.grails.datastore.gorm)
   withTransaction:981, GormEntity$Trait$Helper (org.grails.datastore.gorm)
   call:-1, GormEntity$Trait$Helper$withTransaction$3 
(org.grails.datastore.gorm)
   defaultCall:47, CallSiteArray (org.codehaus.groovy.runtime.callsite)
   call:115, AbstractCallSite (org.codehaus.groovy.runtime.callsite)
   call:143, AbstractCallSite (org.codehaus.groovy.runtime.callsite)
   withTransaction:-1, Name (au.gov.environment.labelname)
   call:-1, Name$withTransaction$0 (au.gov.environment.labelname)
   defaultCall:47, CallSiteArray (org.codehaus.groovy.runtime.callsite)
   call:115, AbstractCallSite (org.codehaus.groovy.runtime.callsite)
   call:135, AbstractCallSite (org.codehaus.groovy.runtime.callsite)
   $tt__doWork:45, BackgroundThread (au.gov.environment.labelname)
   invoke0:-1, NativeMethodAccessorImpl (sun.reflect)
   invoke:62, NativeMethodAccessorImpl (sun.reflect)
   invoke:43, DelegatingMethodAccessorImpl (sun.reflect)
   invoke:498, Method (java.lang.reflect)
   invoke:101, CachedMethod (org.codehaus.groovy.reflection)
   doMethodInvoke:323, MetaMethod (groovy.lang)
   invokeMethod:1217, MetaClassImpl (groovy.lang)
   invokeMethod:1041, MetaClassImpl (groovy.lang)
   invokePogoMethod:1011, InvokerHelper (org.codehaus.groovy.runtime)
   invokeMethod:994, InvokerHelper (org.codehaus.groovy.runtime)
   invokeMethodSafe:97, InvokerHelper (org.codehaus.groovy.runtime)
   doCall:-1, BackgroundThread$_doWork_closure1 (au.gov.environment.labelname)
   invoke0:-1, NativeMethodAccessorImpl (sun.reflect)
   invoke:62, NativeMethodAccessorImpl (sun.reflect)
   invoke:43, DelegatingMethodAccessorImpl (sun.reflect)
   invoke:498, Method (java.lang.reflect)
   invoke:101, CachedMethod (org.codehaus.groovy.reflection)
   doMethodInvoke:323, MetaMethod (groovy.lang)
   invokeMethod:263, ClosureMetaClass (org.codehaus.groovy.runtime.metaclass)
   invokeMethod:1041, MetaClassImpl (groovy.lang)
   call:405, Closure (groovy.lang)
   call:421, Closure (groovy.lang)
   doInTransaction:94, GrailsTransactionTemplate$2 (grails.gorm.transactions)
   execute:140, TransactionTemplate (org.springframework.transaction.support)
   execute:91, GrailsTransactionTemplate (grails.gorm.transactions)
   doWork:-1, BackgroundThread (au.gov.environment.labelname)
   run:22, BackgroundThread (au.gov.environment.labelname)
   ```
   
   Here is where it ends up throwing a validation exception  in 
org.grails.orm.hibernate.support.ClosureEventListener
   
   ```groovy
   protected boolean doValidate(Object entity) {
           boolean evict = false;
           GormValidateable validateable = (GormValidateable) entity;
           if ( !validateable.shouldSkipValidation()
                   && !validateable.validate(validateParams)) {
               evict = true;
               if (failOnErrorEnabled) {
                   Errors errors = validateable.getErrors();
                   throw ValidationException.newInstance("Validation error 
whilst flushing entity [" + entity.getClass().getName()
                           + "]", errors);
               }
           }
           return evict;
       }
   ```
   
   Now... hiberate / gorm is complicated, maybe there's something I don't 
understand, but this seems wrong to me.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to