Envers fails to audit subclass of @Audited @Entity with @Inheritance

Description

steps to reproduce
  1. have a BaseClass:

    1 2 3 4 5 6 7 8 @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn (....) public abstract class BaseClass { .... @Audited public String getSomeProperty() {...} }
  2. and Derived:

    1 2 3 4 5 6 7 @Entity @DiscriminatorValue(value = "...") public class Derived extends BaseClass { .... // no @Audited here .... }
  3. persist instance of Derived

expected
  • insertion audited and value of someProperty saved in AUD table

observed
  • nothing audited

  • most probably because isVersioned returns true for BaseClass, but not for Derived in EnversPostInsertEventListenerImpl:

    EnversPostInsertEventListenerImpl

    1 2 3 4 5 6 7 8 public void onPostInsert(PostInsertEvent event) { String entityName = event.getPersister().getEntityName(); if ( getAuditConfiguration().getEntCfg().isVersioned( entityName ) ) { // zonk here? // auditing seems to be enclosed here }

Environment

None

Status

Assignee

Chris Cranford

Reporter

Piotr Findeisen

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

4.3.9
4.2.15
5.1.0
5.0.9

Priority

Major
Configure