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

   When listening for the saveOrUpdate gorm event it is getting emitted every 
time a transaction context is committed even if a single update or save 
actually happened.  This is happening on [this 
line](https://github.com/spring-projects/spring-framework/blob/master/spring-tx/src/main/java/org/springframework/transaction/support/TransactionTemplate.java#L150)
 of TransactionTemplate `this.transactionManager.commit(status);`
   
   I am unsure if this is intentional or if there is a way to stop this, but if 
any listener needs to process downstream work upon saving data to the database 
and wants to do it in a reactive async manner, this becomes problematic and 
could lead to data integrity or business flow problems.
   
   You can see the gorm saveOrUpdate event emitted many times in [this 
project](https://github.com/Grails-Plugin-Consortium/grails-gorm-events) 
running the following curl command:
   
   `curl -X PUT -H "Content-Type: application/json" -H "Cache-Control: 
no-cache" -H "Postman-Token: 7e9807e3-7df4-f6a3-a04c-1219e00ac546" -d 
'{"name":"Graeme2"}' "http://localhost:8080/persons/1"`
   
   When calling the command the console will log the following:
   
   ```
   INFO grails.app.services.grails.gorm.events.PersonService - GOT 
ValidationEvent 
org.grails.datastore.mapping.engine.event.ValidationEvent[source=org.grails.orm.hibernate.HibernateDatastore@3ccc4ca0]
   INFO grails.app.services.grails.gorm.events.PersonService - GOT 
SaveOrUpdateEvent 
org.grails.datastore.mapping.engine.event.SaveOrUpdateEvent[source=org.grails.orm.hibernate.HibernateDatastore@3ccc4ca0]
   INFO grails.app.services.grails.gorm.events.PersonService - GOT 
SaveOrUpdateEvent 
org.grails.datastore.mapping.engine.event.SaveOrUpdateEvent[source=org.grails.orm.hibernate.HibernateDatastore@3ccc4ca0]
   INFO grails.app.services.grails.gorm.events.PersonService - GOT 
SaveOrUpdateEvent 
org.grails.datastore.mapping.engine.event.SaveOrUpdateEvent[source=org.grails.orm.hibernate.HibernateDatastore@3ccc4ca0]
   INFO grails.app.services.grails.gorm.events.PersonService - GOT 
ValidationEvent 
org.grails.datastore.mapping.engine.event.ValidationEvent[source=org.grails.orm.hibernate.HibernateDatastore@3ccc4ca0]
   INFO grails.app.services.grails.gorm.events.PersonService - GOT 
PreUpdateEvent 
org.grails.datastore.mapping.engine.event.PreUpdateEvent[source=org.grails.orm.hibernate.HibernateDatastore@3ccc4ca0]
   INFO grails.app.services.grails.gorm.events.PersonService - GOT 
PostUpdateEvent 
org.grails.datastore.mapping.engine.event.PostUpdateEvent[source=org.grails.orm.hibernate.HibernateDatastore@3ccc4ca0]
   INFO grails.app.services.grails.gorm.events.PersonService - GOT 
SaveOrUpdateEvent 
org.grails.datastore.mapping.engine.event.SaveOrUpdateEvent[source=org.grails.orm.hibernate.HibernateDatastore@3ccc4ca0]
   INFO grails.app.services.grails.gorm.events.PersonService - GOT 
SaveOrUpdateEvent 
org.grails.datastore.mapping.engine.event.SaveOrUpdateEvent[source=org.grails.orm.hibernate.HibernateDatastore@3ccc4ca0]
   INFO grails.app.services.grails.gorm.events.PersonService - GOT 
SaveOrUpdateEvent 
org.grails.datastore.mapping.engine.event.SaveOrUpdateEvent[source=org.grails.orm.hibernate.HibernateDatastore@3ccc4ca0]
   ```
   


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