entity :
class A{
private int id;
@oneToMany(mappedBy = "a")
private List<B> bList;
}
class B{
private int id;
@ManToOne
private A a;
}
repository :
interfase BRepository{
@Query("select b from B b where b.a.id = ?1")
public List<B> getB(String id);
}
controller :
private BRepository b;
@RequestMapping("/b")
public Object getB(){
return b.getB(1);
}
return JSON in an infinite loop .
Use the @JsonBackReference annotation on the class A, normal results :
class A{
private int id;
@oneToMany(mappedBy = "a")
@JsonBackReference //this property is ignored
private List<B> bList;
}
But when you query a class, the returned results not bList (using @JsonBackference), what can I do to return the bList properties?