I’m trying to implement a pattern in a system, which is called Four-Eyes, or Maker-Checker (More details about this pattern can be found here). I’ve found a demo implementation done using Envers.
The demo relies on Envers to make a helper table containing the history, but in my case, the history is not needed, just the ability to freeze a copy of a record while the same record is being changed.
Someone already have to implement such feature, or anything like it? I need some directions.
If I understood you correctly, your proposal will only solve the approval part of this pattern. How can I deal with the “editing” copy of an entity? In my case, once a change is approved, a user can submit another change, but the unchanged (or the previous approved copy) of an entity must be able to be queried. In a given moment, it’ll be needed to have an editing copy and an approved copy. For this reason, in the example I’ve posted, Envers is used.
You can have a OneToMany association to store intermediary states. Document can have a parent id column for this purpose. Once the entity is frozen, only new child entities are accepted.