I have mapped several java classes, such as Customer, Assessment, Rating, ... in a database with Hibernate. Now I'm thinking of a historical mode for all changes to persistent data. The application is a web application. In the case of deleting (or editing) data, another user should be able to see the changes and discard them. Since the changes are outside the scope of the current session, I do not know how to solve this problem in the form of the Command pattern, which is recommended for canceling the function.
For editing a single value, an approach like this question sounds fine. But what about deleting an entire permanent object? The easiest way is to create a flag in the table if this client is deleted or not. The most difficult way is to create a table for each class where deleted objects are stored. Is there something in between? And how can I integrate these two things into the O / RM system (in my case Hibernate) comfortably, without much noise with SQL (which I want to avoid due to portability) and is still flexible enough?
Is there any best practice?
source share