@JsonIdentityInfo ObjectIdGenerators返回3而不是object

时间:2015-12-13 16:19:33

标签: java rest jpa spring-boot

过去的问题: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

0 个答案:

没有答案