2 Replies Latest reply on Jul 23, 2010 2:19 AM by Adam Warski

    auditquery reads from manytoone entities_aud not entities

    Syed Mahdi Apprentice

      OK it is making me crazy and I just found out what is happening..


      I have a BO that is Audited : Department Employee EmployeeType, Employee has many to one relationship with Department , so in my Department.hbm.xml there is a manytoone tag that defines that relationship.


      Now, both are audited which they should be. When I do



      reader.createQuery().forRevisionsOfEntity(entity, false, true)


      I get a list of  Object[3].


      When i look at the entity it has brought in for department and try to getEmployee() it gives me a ObjectnotFoundException./ I looked at the query its trying to run for the all the Business objects within Department object and i found out that its only searching in _AUD tables for all those Domain/business objects.


      now this is causing me some issues, cos I put the employees before hibernate or envers kicks in, same is happening for my reference tables tat are loaded when the Db is created so no ADD histories are created. Is there a possibility i can tell envers that FOR these domainobjects Do not load data from AUD tables but the original table (those tables are never going to change so the audit tables are always going to remain empty). i still would have to create the _AUD tables for my reference tables (Like Employee type: clerk,teller,manager,supervisor).


      What envers is doing is that when retrieving the Employee audit records its loading the Employee.employeetype for example from the employeType_aud table where the Id is 1 and REVTYPE is ADD or 0. BUt the employeeType_AUD table is empty cos the types were loaded at startup even before envers started.


      Will really appreciate anyhelp.