I need to do versioning on (simple) Java object graphs stored in a document-oriented database (MongoDB). For relational databases and Hibernate, I discovered Envers and am very amazed about the possibilities. Is there something similar that can be used with Spring Data Documents?
I found this post outlining the thoughts I had (and more…) about storing the object versions, and my current implementation works similar in that it stores copies of the objects in a separate history collection with a timestamp, but I would like to improve this to save storage space. Therefore, I think I need to implement both a “diff” operation on object trees and a “merge” operation for reconstructing old objects. Are there any libraries out there helping with this?
Edit:
Any experiences with MongoDB and versioning highly appreciated! I see most probably there won’t be a Spring Data solution.
We’re using a base entity (where we set the Id, creation + last change dates,…). Building upon this we’re using a generic persistence method, which looks something like this:
The delta method looks like this (I’ll try to make this as generic as possible):
Our delta entity looks like that (without the getters + setters, toString, hashCode, and equals):
Hope this helps you getting started 🙂