is there possibility to set Hibernate Envers so that when ever I delete original entity all revisions of it are deleted also? I need to track the history only when the original entity exists.
Asked
Active
Viewed 862 times
1 Answers
0
I don't think Envers itself offers such an option, so you have to do stuff yourself.
Options that come to mind:
- a database trigger on either the entity or the related Envers table, that deletes the history on a delete of the entity or on the insert of a delete change.
- a JPA listener. Note that a JPA listener is very limited on the action it may perform, but issuing a SQL statement via
JdbcTemplate
should be fine.

Jens Schauder
- 77,657
- 34
- 181
- 348
-
Thanks, I also was thinking about something you are suggesting but I wanted to be sure there isn't any easier built in option in Envers. Anyway thanks a lot for your time – Jakub Znamenáček Feb 03 '21 at 07:52