I want to call a service inside my grails beforeDelete () domain objects. Unfortunately, it always works reproducibly when an event is triggered. I built an example that reproduces the problem. Domain Object:
class Gallery { def myService def beforeDelete() {
Service:
class MyService { String say() { "hello" } }
Testing Controller:
class DeleteController { def index() { Gallery.list().each { it.delete() } } def create() { def gallery = new Gallery() gallery.save() } }
If I run the application and call create followed by an index, I get:
Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [testbeforedelete.Gallery
I want to make a call that is a little more complicated than this example. I canβt explain this behavior, and I donβt know how to handle it. I know that Hibernate events need special care, but I'm stuck.
source share