The Envers only use the annotation on the property level and ommit the annotation on the class level.
The AuditOverride annotations are read at the class level on any audited entity. Those annotations are composed into a couple lists in the AuditedPropertiesReader where they're used to determine whether or not a property for a given class is considered audited as properties are iterated on that entity hierarchy. As you pointed out and as I see locally, the only real problem with @AuditOverride seems to be that when you specify an @AuditJoinTable, that part of the override annotation gets ignored and thus the audited object name does not use the specified override as you describe. I have a fix locally that will cache the @AuditJoinTable annotation on the @AuditOverride and when processing overridden properties, that join-table name will be used for the audited object. There is one caveat, the solution doesn't work for @Audited(auditParents = SuperClass.class). I don't necessarily think that is a problem because that part of the annotation is deprecated and scheduled for removal in the next major release. If you want to fix your code in 5.x so its compatible with 6, I would suggest using the following:
@Entity
@Audited
@Table(name = "OtherAuditedTable")
@AuditOverride(forClass = SuperClass.class, name = "superStringList",
auditJoinTable = @AuditJoinTable(name = "CustomOverrideAuditJoinTable" ))
I'll continue to look at the auditParents part of @Audited to see if there is anyway to support that but I would suggest the code path above just for future portability either way. |