6 Replies Latest reply on May 28, 2009 12:11 PM by ax123man

    Identify which columns have changed

    kashmr

      I am analysing to use envers to audit some entities on my project.
      My app is seam + hibernate 3.2.6 + envers 1.1.0

      I am facing an issue that I am not sure if envers can support.

      I need to get and show on a report, only the columns that have changed, but
      Envers log the full entity.

      How could I identify only the columns that were changed?

      I need to show in my report something like below:

      WhoChanged, dateModified, columnModified, OldValue, NewValue

      Is it possible to do it using envers?
      Any ideas?

      Thanks

        • 1. Re: Identify which columns have changed
          adamw

          Hello,

          it's possible in a way :). What you need to do, is first to create a revisions-of-entity query to grab the history of an entity, along with the meta-data. You can also narrow it to return only entities between some revisions, for example.

          Then, when you have that list, you can simply compare each entity and the next one to see which fields changed.

          --
          Adam

          • 2. Re: Identify which columns have changed
            kashmr

            Hi,

            So you are saying that the only way is comparing each revisionEntity of the next?
            And this comparison can only be done using Java?

            Thanks
            Marcos

            • 3. Re: Identify which columns have changed
              adamw

              Hello,

              yes, I think so ... there's no possibility to easily compare a database row with the "next revision". So the comparision would have to be done in Java.

              Adam

              • 4. Re: Identify which columns have changed

                Hello,

                an utility class which compares / give a list of changes would be expected solution. In other case almost all of the envers clients must write own implementation of such tool -> common solution is much better, I think.

                regards
                Albert

                • 5. Re: Identify which columns have changed
                  adamw

                  Agreed :). If somebody could contribute such code, that would be great.

                  Adam

                  • 6. Re: Identify which columns have changed

                    has anyone out there made progress on this functionality? I'm wondering if they could post a bit on what their approach was. How do you generically iterate/compare properties? How do you define which associated entities are "part of" the comparisons. Is there any code, or even patterns in the envers code that can be leveraged (other than querying for the revisions).