我有以下两个领域对象,它们之间具有一对多关系 1.男孩(Boy.java) 2.循环(cycle.java) 它是一个基于springboot的应用程序,我对此应用程序进行了Javerse存储库实现。
使用JQL [javerse查询语言]获取阴影时,它无法正常工作
1.Pom文件我添加了javers-spring-boot-starter-sql依赖项
2.Boy实体类
@Entity
@Table(name = "boy")
public class Boy implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@Column(name = "name")
private String name;
@OneToMany(mappedBy = "boy")
private Set<Cycle> cycles = new HashSet<>();
}
3.Cycle实体类
@Entity
@Table(name = "cycle")
public class Cycle implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@Column(name = "cycname")
private String cycname;
@ManyToOne
@JsonIgnoreProperties("cycles")
private Boy boy;
}
4。Boy and Cycle存储库已使用@JaversSpringDataAuditable注释
6。使用Javerse查询语言的审核获取API
@PostMapping("/audit/shadowsboy/{id}")
@Timed
public String getShadows(@PathVariable Long id) {
JqlQuery queryBuilder = QueryBuilder.byInstanceId(id, Boy.class).withScopeCommitDeep().build();
List<Shadow<Object>> shadowList = javers.findShadows(queryBuilder);
System.out.println("shadows: ::::::::::::::::::::::::::" + javers.getJsonConverter().toJson(shadowList));
return javers.getJsonConverter().toJson(shadowList);
}
输出: 在给男孩添加一个循环后,按男孩id的findShadows返回
{
"commitMetadata": {
"author": "anonymousUser",
"properties": [],
"commitDate": "2019-07-20T13:11:24.076",
"commitDateInstant": "2019-07-20T07:41:24.076Z",
"id": 2.00
},
"it": {
"id": 951,
"name": null,
"cycles": []
}
},
{
"commitMetadata": {
"author": "anonymousUser",
"properties": [],
"commitDate": "2019-07-20T13:04:26.988",
"commitDateInstant": "2019-07-20T07:34:26.988Z",
"id": 1.00
},
"it": {
"id": 951,
"name": "gajendran.g",
"cycles": []
}
}
]
预期结果:cycles对象不能为空或为空