Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java @JsonIdentityInfo ObjectedGenerators返回3而不是对象_Java_Rest_Jpa_Spring Boot - Fatal编程技术网

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个老师。班级?