Java @JsonIdentityInfo ObjectedGenerators返回3而不是对象
过去的一个问题: 代码 老师Java @JsonIdentityInfo ObjectedGenerators返回3而不是对象,java,rest,jpa,spring-boot,Java,Rest,Jpa,Spring Boot,过去的一个问题: 代码 老师 @ManyToMany @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class) private Set<SchoolClass> classes = new HashSet<>(); @manytomy @JsonIdentityInfo(生成器=ObjectedGenerators.IntSequenceGenerator.class) 私有
@ManyToMany
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class)
private Set<SchoolClass> classes = new HashSet<>();
@manytomy
@JsonIdentityInfo(生成器=ObjectedGenerators.IntSequenceGenerator.class)
私有集合类=新HashSet();
学校班级
@ManyToMany
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class)
private Set<Teacher> teachers = new HashSet<>();
@manytomy
@JsonIdentityInfo(生成器=ObjectedGenerators.IntSequenceGenerator.class)
私有集教师=新HashSet();
教师的输出现在是:
{
"id": 1,
// reduced content
"classes": [
{
@id: 1,
id: 1,
// reduced content
},
3 // <- no class object
]
}
{
“id”:1,
//减少的内容
“类别”:[
{
@id:1,
id:1,
//减少的内容
},
3//您是否尝试了(generator=ObjectiveGenerators.PropertyGenerator.class)?我不确定,但您是否可以在集合上使用注释,对各自的类进行注释并尝试?您是否可以将此注释放在类本身上:@JsonIdentityInfo(generator=ObjectiveGenerators.IntSequenceGenerator.class)公共类教师{//}学校班级也一样吗?这现在起作用了;但是从学校班级我得到了4个(一个班),你是说学校。班级有4个老师。班级?