I'm afraid the paths you are storing in MongoDB won't be very useful, since they are simply the default toString() representation of the referenced collection item. In order to use this path to access the property via java-object-diff, you'd need to be able to deserialize it to an actual instance of an object that has the same identity (equals == true
) as the one you want to reference.
There are ways to do that, like writing a custom serializer for the PropertyPath to serialize a deserializable version of the reference item, but that leads to pretty verbose JSON and is rather fragile.
I personally don't recommend storing the diff in a database, but rather compare two document versions on demand. Depending on your scenario that may or may not cause performance issues. If it does, there are usually ways to cache the information you actually need, without storing the entire diff in the database.
I once had the same problem when I tried to generate a Github-like activity stream. I first approached it by stor