使用 Javers 审核 MongoDB 子文档

Audit MongoDB Subdocument with Javers

我正在尝试使用 Javers 审核对子文档的更改,但是当我使用 findChanges:

时,子文档更改没有显示出来

下面是文档和子文档的结构:

{
  "id": "5fafa42d99fa9d005fc288a1",
  "lastModifiedDate": "2020-11-14T09:32:45.118+00:00",
  "workflowState": {
    "isTerminus": false,
    "label": "Under Consideration",
    "entry": false
  },
  "workflowId": "5f9ef05e607b75554aa7e93f",
}

但是,当我使用下面的代码对此实体进行更改时,只有 属性 lastModifiedDate 出现在更改中:

WorkflowState newState = workflowService.transitionIssue(issue, transition);

IssueDTO issueDTO = new IssueDTO(
    issue.getId(),
    new Date(), // lastModifiedDate
    newState, // also new but is not getting listed in changes
    issue.getWorkflowId()
);

Issue entity = Issue.fromIssueDto(issueDTO);

issueService.save(entity);

下面是我用来检索更改的代码:

return javers.findChanges(QueryBuilder.byInstance(issue).build());

我是不是漏掉了什么?

看来我需要在查询中使用方法 .withChildValueObjects(),如下所示:

javers.findChanges(
      QueryBuilder
      .byInstance(issue)
      .withChildValueObjects()
      .build()
);