Mapping Hibernate envers tables

You can actually use audit entities in HQL, but the metamodel for the entities might be a bit non-obvious. Look up the metamodel for the fully qualified name of the entity class + _AUD to see what attributes you have available.

You can do something like the following for example:

session.createQuery("select e, a from MyEntity e join my.company.MyEntity_AUD a on e.id = a.originalId.id", Object[].class)
.getResultList();
1 Like