When saving an audited (@CreatedDate, @LastModifiedDate) document with nested audited documents, the two dates will be also reflected in nested docs.
This is the scenario:
DocumentA.java
public class DocumentA {
@Id
private String id;
@Version
private Long version;
@CreatedDate
private Long createdDate;
@LastModifiedDate
private Long lastModifiedDate;
// getters and setters
}
DocumentB.java
public class DocumentB {
@Id
private String id;
@Version
private Long version;
@CreatedDate
private Long createdDate;
@LastModifiedDate
private Long lastModifiedDate;
private DocumentA docA;
// getters and setters
}
DocumentA is already stored in db having its createdDate and lastModifiedDate set. Then, when saving new DocumentB with nested DocumentA, the 2 dates of nested DocumentA will be modified to the same values just set for DocumentB. This only happen in nested document, while stored DocumentA is not touched (luckily!). The expected behaviour is that nested document will remain exactly the same just set via code (it means the same of the original documentA)