Envers query API: cannot traverse relation if target entity is mapped with JOINED subclass mapping/Unrelated property joins do not work when target entity is Mapped with JOINED subclass mapping

Description

An exception is thrown when querying for entities with Envers where an association is traversed and the target entity is mapped with inheritance strategy 'joined subclass'. This issue only occurs when using AuditStrategy 'ValidityAuditStrategy'. Consider the following example:

The problem is that the REVEND property (in the ValidityAuditStrategy) is not available for the joined class (EntityC) because EntityC has InheritanceStrategy JOINED.
Envers creates a JPQL query for its audit queries, so this issue exists in hibernate core. It seems that whenever an entity is joined with unrelated property join and that Entity has InheritanceStrategy JOINED, no properties of a superclass may be used in the query. I have created a simple example which reproduces this problem in hibernate-core:

In this example the property 'propB' of EntityC is not available since it is defined on superclass EntityB.

Here are the stack traces of the two examples:

The Envers example:

The JPQL example:

Environment

None

Assignee

Chris Cranford

Reporter

Felix Feisst

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure