2 Replies Latest reply on Jan 17, 2011 11:29 AM by teinacher

    Lazy Loading of audited entites with revision type 'delete'

    teinacher Newbie



      I'm doing an audit query for all deleted objects, which looks like this:


      AuditQuery queryDeleted = reader.createQuery().forRevisionsOfEntity(

                      MyClass.class, false, true).add(



      The property "org.hibernate.envers.store_data_at_delete" is set to true, so that the entities are filled with the neccesary data. My class has some relationships:




      public class MyClass {



          @Cascade(value = CascadeType.ALL)

          private MyOtherClass otherClass;




      The related objects are also annotated with @audited. So the related objects in the result list of the auditquery are proxies and when I try to initialize the proxies via Hibernate.initialize I get an ObjectNotfoundException. However, I tried this with other entities of the revision type 'ADD' and 'MOD', initializing works without throwing an exception. What am I doing wrong here?


      My code looks like this:


      List queryResult = queryDeleted.getResultList();

      List<MyClass> result = new ArrayList<MyClass>();


              for (Object object : queryResult) {

                  Object[] oArray = (Object[]) object;

                  MyClass c = (MyClass) oArray[0];