auditmongodb子文档

n8ghc7c1  于 2021-07-06  发布在  Java
关注(0)|答案(1)|浏览(344)

我试图使用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());

我是不是漏了什么?

wgxvkvu9

wgxvkvu91#

看来我需要用这个方法 .withChildValueObjects() 在这样的查询中:

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

相关问题