1 Reply Latest reply on Feb 6, 2017 5:14 PM by ccranfor

    retro-actively fixing _AUD tables for a database that was populated without envers

    justkeys

      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?