过去的问题:Spring boot with JPA and ManyToMany: JsonIdentifyInfo not working properly
教师
@ManyToMany
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class)
private Set<SchoolClass> classes = new HashSet<>();
SchoolClass
@ManyToMany
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class)
private Set<Teacher> teachers = new HashSet<>();
老师的输出现在是:
{
"id": 1,
// reduced content
"classes": [
{
@id: 1,
id: 1,
// reduced content
},
3 // <- no class object
]
}
在数据库本身中,所有内容都是正确链接的。
来自getClasses()
方法的Teacher
在数组中也有正确的对象。
为什么只有3
而不是对象?
btw:正确的对象ID为4