Details
Assignee
Chris CranfordChris CranfordReporter
Former userFormer user(Deactivated)Components
Fix versions
Priority
Major
Details
Details
Assignee
Chris Cranford
Chris CranfordReporter
Former user
Former user(Deactivated)Components
Fix versions
Priority
Created May 16, 2014 at 12:02 AM
Updated September 28, 2023 at 11:54 AM
JPA only allows an entity to extend a mapped-superclass, but Hibernate
provides an extension that allows an embeddable to extend a
mapped-superclass.
The bug is that the default audit behavior of a mapped-superclass depends on the context in which it's used. It should be be consistent, regardless of the context it is used.
Assume we're using AccessType.FIELD and there are no AuditOverride(s).
In the following, the declared fields of A are audited; the fields declared
in B are not audited. In this case, it doesn't matter if the subclass (A)
is audited, the default for the mapped-superclass is that it will not be
audited.
@Entity @Audited public class A extends B { ... } @MappedSuperclass public class B { ... }
In the following all declared fields in A are audited, including the
embeddable 'b', and all fields in B and AbstractB are also audited. In
other words, the default for the mapped-superclass depends on whether the embedded field is audited.
@Entity @Audited public class A { ... @Embedded private B b; ... } @Embeddable public class B { ... } @MappedSuperclass public class AbstactB { ... }
The behavior when an embeddable extends a mapped-superclass should be made consistent with the behavior when an entity extends a mapped-superclass.
In other words, a "global" @Audited should not have an effect on fields/methods from mapped-superclasses. To audit them, either the mapped-superclass (or its relevant fields/methods) should be audited, or an @AuditOverride should be used.