Hibernate Envers: @Audited on a subclass
A very good question. There was the same discussion on the jboss
developers forum in 2013 year. And the answer was from the founder and project lead of Hibernate Enver:
You would have to get the superclass audited somehow. Currently there's no other way to specify such metadata except for annotations.
In the same discussion tree, according to the fact that a parent class should also be annotated, there was suggested to annotate them in Runtime. But this decision seems to be ugly and is not suitable in your case: you can annotate the parent class manually.
As a workaround, if you don't want the parent class being audited, you can try to create a base abstract MappedSuperClass
which essentially will be the same as Parent
, while Parent
will be just its descendant, and then try to put @AuditOverride
again for the Child
class. It is possible that it will "skip" audit for Parent
class and do it for Child
.
Try to mark parent and child classes with @Audited annotation but for parent class add @Audited(targetAuditMode = NOT_AUDITED)