We introduced envers late in the project. This means we have many entities in our db which have not a single revision in their _AUD table. This causes these queries to fail with javax.persistence.EntityNotFoundException, if it happens to involve such entity, probably because there is no representation for that entity at that rev.
reader.createQuery().forRevisionsOfEntity(entity.getClass(), false, true).add(AuditEntity.id().eq(entity.getId())).getResultList();
I got this query to work, after manually inserting the missing entity in its _AUD table, with a rev smaller than the one i was querying for.
Is there a way to handle this problem: maybe some script to insert all missing entities with rev=0? Or a patch such that this EntityNotFoundException is handled by taking the "current" version for such entities?
This ties back into a feature request https://hibernate.atlassian.net/browse/HHH-8093. It is already listed as a possible inclusion as part of Hibernate 6.0.