I am using hibernate envers with Grails, defining some entities with @Audited to let them audited by the API. Some entities should not be audited, so I am defining @Audited(... NOT_AUDITED) which runs also smoothly.
But this time, I have a relationship defined following
static hasMany = { foos : Foo }
Foo is also declared as NOT_Audited at class level, but envers is ignoring this and searching for an AUDIT table. However, I have seen that it might be necessary to add the annotation @NotAudited to the relationship to inform envers that the type should not be audited.
So, I have tried:
static hasMany = {@NotAudited foos : Foo }
// Or desperately:
@NotAudited
static hasMany = { foos : Foo }
Either it seems that my approach is false or that GORM is ignoring the annotation.
Does anyone have experience with it where it is not enough to define "Not_Audited" at class level like
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
class Foo{
...
}
@Audited
class Bar{
static hasMany = { foos : Foo }
...
}
EDIT: Maybe good to mention that static hasMany = {@NotAudited foos : Foo }
runs into compilation error. So, maybe my problem is just how to add the annotation to the relationship.
I don't know if you found your answer, but you need to overload the getter, and put the annotation on it :
@NotAudited
def getFoos() {foos}
At least, it works for direct associations...