We're updating the issue view to help you get more done. 

No entity type expressions can be used in the Envers Query API

Description

While HQL supports entity type expressions (see user guide 15.32) the envers query API does not support them.

I suggest to introduce four new methods on AuditEntity: entityType(Class entityType), entityType(String entityName), entityType(String alias, Class entityType) and entityType(String alias, String entityName) which all return an AuditCriterion. The first two are needed because we might specify the desired type either by entity name or by class literal (A translations to the effective audited entity name must be made in the implementation). The other two methods are necessary such that a custom alias can be specified on which the type check should be applied.

Code example:

1 2 3 4 AuditReader reader = ...; reader.createQuery() .forEntitiesAtRevision(EntityA.class, 3) .add(AuditEntity.entityType(EntityB.class))

This example will only return those entities of type EntityA which are really of (sub-)type EntityB.

Environment

None

Status

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

5.2.9

Priority

Major