5

We have an application that is already in production and it is using Envers to do auditing.

Now we are going to release an update in which we audit a new kind of entity. However this entity already exists in the production environment, only it was not audited so far.

We have tried in a test environment containing existings records, and it crashes upon saving because Envers cannot find a previous revision for the entity being saved.

What is the approach to takle this issue ?

It would be great for instance if one could specify the date from which an entity should be audited.

Sam
  • 13,934
  • 26
  • 108
  • 194
  • Are you using the `validity audit strategy`? – Russ Cam Jul 06 '15 at 12:17
  • yes, we are using this strategy. – Sam Jul 06 '15 at 12:19
  • 1
    If I recall correctly the last time I used Envers in 2012, the validity audit strategy throws an exception but the default strategy does not. I think you may need to manually insert data into the relevant audit table for the entity to provide Envers a starting revision to work with, based on what the validity audit strategy does as described here - http://envers.bitbucket.org/ – Russ Cam Jul 06 '15 at 12:22
  • that's not good :( We have many entities potentially impacted since we use REVCHANGES to track all changes. I would have thought there would be an easier way than scripting.... – Sam Jul 06 '15 at 12:46

1 Answers1

6

You have to, manually, write a script for this. Shouldn't be that hard, just create a single row in your revision table and write "insert audit records" for this revision for all your audited entities.

Roger
  • 1,944
  • 1
  • 11
  • 17