Hibernate, save the previous state of an object

后端 未结 5 2274
悲哀的现实
悲哀的现实 2021-01-03 09:08

Is there any generally accepted, proven-to-work way using hibernate, that keeps a history of an entitys changes in the database?

We need to keep track of quite some

5条回答
  •  难免孤独
    2021-01-03 09:21

    Hibernate Envers from JBoss is probably what you are looking for:

    The Envers project aims to enable easy auditing/versioning of persistent classes. All that you have to do is annotate your persistent class or some of its properties, that you want to audit, with @Audited. For each audited entity, a table will be created, which will hold the history of changes made to the entity. You can then retrieve and query historical data without much effort.

提交回复
热议问题