1 Reply Latest reply on Dec 22, 2011 8:21 PM by Steve Mactaggart

    Issue with envers tracking more changes than occur

    Steve Mactaggart Newbie

      I have been recently working on using Envers to produce a highly detailed audit trail of all changes in our system.


      We have been tracking changes per entity using Envers since the inception of the project, but are now just at a stage where we need to actually retreive the next level of detail from our Audit logs.


      Now that I can actually look at the data being tracked, I have noticed that Envers is tracking versions of things that haven't changed.


      My example is:


      A Journal has multiple Items, each of those items have a Location, and Account and an Amount.


      Location and Account are actually other entities in the system, while the Amount is just a BigDecimal on the Item Entity.


      When I create a new Journal, envers records an ADD for Journal, and 2 ADD's for the Item's, but it also records and UPDATE for the 2 Accounts from each line.


      Debugging the hibernate SQL there is NO update command issued for the Account (nor should there be).


      When I chech the Account_AUD table I see 2 entries for each Account, the initial insert (prior to the Journal creation) and an update revision, but there are NO field differences between the 2 records.


      What I find wierd is that, from my perspective, Account and Location should look the same to Envers..  If 1 was going to be versioned why didn't the other one?


      What I really want is ONLY the 3 items that have actually been added to be tracked by Envers..


      Is this a known issue?  or any pointers to where I should look to try and resolve this issue?




        • 1. Re: Issue with envers tracking more changes than occur
          Steve Mactaggart Newbie

          As usual, take the time to write up the issue and then keep hunting and you'll eventually find the issue.


          It seems there was a subtle difference between Account and Location, the Location didn't have a reverse mapping for a list of all Items, where as the Account did.



              @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "account")

              private List<JournalItem> journalItems = new ArrayList<JournalItem>(0);


          This mapping is not actually used in our system, so I was able to remove it and when I did so EnVers stopped tracking the Account as changed when the Journal's were added.


          Hopefully this might help others stumbling on the same issue.