spring-data-mongodb
spring-data-mongodb copied to clipboard
Spring Data MongoDB auditing doesn't work for embedded documents [DATAMONGO-1440]
Egor Lyashenko opened DATAMONGO-1440 and commented
I'm trying to introduce auditing by using @LastModifiedDate annotation. It works fine for top-level documents but I've faced with the problem for embedded objects.
For example, by default, when I save document object with inner list, updated value is set only for this document but not for any object from the children list. But in this case I want to audit them too
Affects: 1.9.1 (Hopper SR1)
Reference URL: http://stackoverflow.com/questions/37324188/spring-data-mongodb-auditing-doesnt-work-for-embedded-documents/37346938#37346938
5 votes, 6 watchers
Abbe Resina commented
I am interested in this in a first approach but there may be some policy issues depending on the uses cases.
For instance, if you want to track the @LastModifiedDate on the parent and on the children, does it mean that when a child is modified, the parent should also be modified ? both parent and child are in the same document, and it make sens to have the parent date updated ; but then it may not be what you really want if you need to track the changes on the parent's fields only...
Hey there, any update about this issue?
Auditing is targeting the aggregate as a whole and not individual parts of it. Looking at the linked SO reference the ChildDocument is part of the aggregate. To enable auditing for ChildDocument those would need to be stored individually using DBRef to link them to the ParentDocument.