spring-data-mongodb icon indicating copy to clipboard operation
spring-data-mongodb copied to clipboard

Spring Data MongoDB auditing doesn't work for embedded documents [DATAMONGO-1440]

Open spring-projects-issues opened this issue 9 years ago • 3 comments

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

spring-projects-issues avatar May 28 '16 21:05 spring-projects-issues

pfonseca commented

Hello all. Is there any update about this feature? 

spring-projects-issues avatar May 15 '20 06:05 spring-projects-issues

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...

spring-projects-issues avatar Jun 23 '20 09:06 spring-projects-issues

Hey there, any update about this issue?

scarm01 avatar Jan 30 '22 10:01 scarm01

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.

christophstrobl avatar Jun 01 '23 06:06 christophstrobl