Make default audit behavior of extending a mapped-superclass with an embeddable consistent with extending with an entity

Description

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.

follows up on

Activity

Chris CranfordNovember 27, 2021 at 9:48 AM

Not included in 6.0.0.Alpha1; reopened.

Steve EbersoleDecember 6, 2018 at 3:43 PM

Preparing Alpha1 release

Former userJuly 24, 2014 at 7:44 PM

I removed the 4.2.x and 4.3.x version because this change in behavior will break applications that use an embeddable that extends a mapped-superclass.

Former userMay 28, 2014 at 1:28 AM

Tests from https://hibernate.atlassian.net/browse/HHH-8908#icft=HHH-8908 have be updated to show expected results and commited against this issue. Failing tests were marked FailureExpected.

Details

Assignee

Reporter

Fix versions

Priority

Created May 16, 2014 at 12:02 AM
Updated September 28, 2023 at 11:54 AM