1

I'm trying to use grails audit-logging plugin. It seems to do what I need to do.

But, I'm having problem referencing id for a domain class where id is automatically generated.

class Person {
 static auditable = true

 String name
 String email


 def onSave = { newState ->
     println "new person inserted"

     // I want to get id of newly inserted person 
     // When I do newState[id], I get null

     // newState[name] works as expected
 }

}

When I try to reference id as for other attributes, I get null.

How can I get reference to id so that I can get id of newly inserted Person entity?

4

1 回答 1

1

最近合并了一个拉取请求,以完成正在寻找的工作。

快照版本 (1.0.1-SNAPSHOT) 将很快推出,之后将尽快发布版本 (1.0.1)。同时,您可以克隆插件并内联使用它。

由于上述 PRid的一部分可用于onSave事件挂钩,但现在它已经可用于日志记录并启用 id 日志记录到AuditEventLog表,插件提供了一个配置设置:

//Config.groovy
auditLog {
    logIds = true // to log ids of objects in audit table
}
于 2014-05-13T06:11:44.380 回答