Search code examples
grailsonloadauditaudit-trailaudit-logging

Grails onLoad() audit


I see that grails-audit plugins provide way of logging onCreate() onUpdate() events, but I also need to track onLoad() events.

Is there any standard way to do it using any plugin? Or I need to implement it myself?


Solution

  • You can add onLoad closure to the domain class. It will be executed when the object is first loaded from the database.

    class Foo {
        int bar;
    
        def onLoad = {
            // onLoad fired
        }
    }