The main one was that we offer our product in SaaS and the we give our customers the run-time ability to tune audit configuration – each enterprise may have different needs and sometimes they require that some data is not retained or not retained longer than X. In this case it would not be possible to ensure there always is some previous record.
I would say a good compromise for this would be to first apply the predicate limitation condition when you query historical records for whatever business operations your SaaS application does. At the database level, you could always apply the data pruning logic to retain 1 record beyond the restriction. So for example, if you wanted to retain only the last 45 days worth of history, you'd retain that plus the next chronological entry that exceeds that predicate. Perhaps a good way to offer this might be to introduce this pruning notion as a part of Envers proper as a feature users could opt-in to? I added this PR a while back https://github.com/hibernate/hibernate-orm/pull/1664 and I am still debating this or not. |