hibernate restore deleted entities
Is there a third-party library which add restore deleted entities feature? i need something like Hibernate envers which creates entities and map them to tables at runtime, but a lot simpler! i just need two tables for each entity s开发者_JAVA百科o that when the entity was deleted it would be moved to the other table.
Perhaps a simpler approach is to never allow anything to be deleted from the table. Instead just have a deleted INT(1) DEFAULT 0
column that specifies whether or not a row has been deleted. Then you can easily get a list of all rows/entities that have been deleted, and undelete any/all that you want by just clearing the deleted
flag.
The nice thing about such an approach is that it is ORM-agnostic. You can choose any desired lightweight alternative to Hibernate that you like, and they will all play nicely with this kind of technique. The downside is that you have to do a bit of manual work to get the undelete functionality implemented.
精彩评论