I would suspect non RDBMS would also be supportable. Concept being that each time an object is modified, the dirty fields of the given object (before and after) are persisted in a document/table, with any custom contextual information that can be provided to the persistence manager.
Envers essentially provides this behaviour by creating separate tables in a different connection/database to track changes to given entities. I realize that JPA/JDO do not specify any of this, but was wondering if there was an easy way to create/implement something like this with DataNucleus. I would essentially see if as putting a listener on the 'commit' phase, checking for dirty fields, and persisting the change of the fields with the object identifier in a table/document. My immediate use case is RDBMS, but NOSQL could be interesting to support as well.
My problem is multi-fold.
1) I'm not sure how to put a listener on any 'commit'. Rather, there seems to be separate listeners for 'create', 'update', 'delete'.
2) Once the listener triggers, I'm not sure how to retrieve which fields are 'dirty'. I see there is a `JDOStateManager`, but not sure how to access it from an `InstanceLifecycleEvent`. I suspect it must be from a `getPersistentInstance()` but I cannot seem to find a helper method anywhere that retrieves a `JDOStateManager`.
3) Even once I am able to get the dirty fields via the `JDOStateManager`, I do not know how to retrieve the original value of the field without needing to re-read the object from the DB
Any suggestions would be greatly appreciated.