Hibernate, save the previous state of an object

后端 未结 5 2283
悲哀的现实
悲哀的现实 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:42

    I've had exactly the same problem. One way round it is to lock() with the previous state and then merge() with the new state, rather than doing update() with just the new state.

    Then hibernate is aware of the before/after and it is available in the interceptors/event listeners.

    HTH.

提交回复
热议问题