简体   繁体   中英

Are event listeners supposed to fire when using MongoDB GORM plugin in Grails?

When using the Grails MongoDB GORM Plugin (v 1.0.0.GA) standalone (ie WITHOUT the Hibernate jars), are the listener events supposed to work?

I've got domain classes with afterInsert, afterUpdate, etc but the event either doesn't fire or the methods are just not getting called.

I'm not seeing any specific guidance on this in the plugin docs. Does anyone know what's supposed to happen? Thanks.

Answering my own question for the benefit of others who may find it:

Apparently, when using MongoDB/GORM without Hibernate, GORM finds the event listeners by looking for the method signature on your domain object class. A closure won't do work (despite the fact that it will work when using Hibernate).

Thus, you cannot use a pattern like this:

class A {
    int blah
    String foo

    def afterInsert = { ... }
}

Instead, do this:

class A {
    int blah
    String foo

    def afterInsert() { ... }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM