jamesfredley commented on code in PR #16652:
URL: https://github.com/apache/grails-core/pull/16652#discussion_r4341193605


##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormValidationApi.groovy:
##########
@@ -108,9 +108,7 @@ class HibernateGormValidationApi<D> extends 
GormValidationApi<D> {
                     validator.validate instance, errors
                 }
             } finally {
-                if (!errors.hasErrors()) {
-                    session.setHibernateFlushMode(previous)
-                }
+                session.setHibernateFlushMode(previous)

Review Comment:
   Do not restore AUTO or COMMIT while a failed managed instance is still in 
the session. Evict it, or leave MANUAL, before the restore. Restore immediately 
when the instance is unattached or validation succeeded. Same change in the 
Hibernate 5 API. Please cover `failOnError=true` with an invalid managed entity 
followed by a query or commit that must not throw from the flush.



-- 
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