In Envers, is there any way to intercept a revision and prevent it from being written at all?

Hi –

as far as I can tell, Envers listeners and interceptors can be used to further shape the revision entity that is written to the revinfo table, but there is no way to just cancel a revision from being written at all.

Do I have that right? Ideally, I’d like to check some thread-local variable and conditionally say “if it’s X, then cancel the revision from being written to either revinfo or the entity _aud tables”.

Thanks in advance for your answers.

I guess you can configure a custom org.hibernate.envers.audit_strategy similar to org.hibernate.envers.strategy.internal.DefaultAuditStrategy and simply override the perform method to skip processing based on your condition.

1 Like

That worked! Thanks so much.