I'm looking for a consistent way to remove Envers historical data from the DB, i.e. using the Envers API, but I failed. The only way I found is to write low level DML queries against the audit tables, but this approach leads to the severe risk of Envers metadata consistence damage, with umpredictable consequences. Do you wonder why we might need such a feature? There are contexts when it would be useful, or even required, to provide a way to remove historical data permanently, either after a given expiration, or upon user request (for example when right to be forgotten applies). I know that it's possible to exclude selectively the auditing through the @NotAudited annotation and the like, but I think that it's a reasonable requirement to have a default scenario with an entity audited, but the option to erase the audited data of a given entity (identified by its identifier) when required. |