title: Service access in beforeDelete()
body: <p>I want to call a service inside my grails domain objects beforeDelete() event. Unfortunately it always crashes reproducibly when the event is fired. I built an example that reproduces the problem. The domain object:</p>
  
  <pre><code>class Gallery {
  
      def myService
  
      def beforeDelete() {
              // System.out.println(myService); // not even this works, same error!
          System.out.println(myService.say());
      }
  }
  </code></pre>
  
  <p>The service:</p>
  
  <pre><code>class MyService {
  
      String say() {
          "hello"
      }
  }
  </code></pre>
  
  <p>The test controller:</p>
  
  <pre><code>class DeleteController {
  
      def index() {
  
          Gallery.list().each {
              it.delete()
          }
      }
  
      def create() {
          def gallery = new Gallery()
          gallery.save()
      }
  }
  </code></pre>
  
  <p>If I start the application and call create followed by index I get:</p>
  
  <pre><code>Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [testbeforedelete.Gallery#1]
  </code></pre>
  
  <p>What I want to accomplish is to call my service, which is a bit more complicated than this example. I cannot explain this behavior and I don't know how cope with this. I know that the Hibernate events need special care yet I'm stuck.</p>