Я пытаюсь решить проблему рекурсии бесконечности, но безуспешно!проект: весенняя загрузка и postgresql
У меня есть 3 сущности: курс, план курса и расписание курса:
public class Course implements Serializable {
private static final long serialVersionUID = -6645577819394287204L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
@OneToMany(mappedBy = "course", cascade = CascadeType.REMOVE)
@OrderBy("rank ASC")
private List<CourseOutline> outlines;
....
}
public class CourseOutline implements Serializable {
private static final long serialVersionUID = -6645577819394287204L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
@ManyToOne
@JoinColumn(name = "course", nullable = false)
@JsonIgnore
private Course course;
private Integer rank;
@OneToMany(mappedBy = "outline", cascade = CascadeType.REMOVE)
@OrderBy("day DESC, started ASC")
private Set<CourseSchedule> schedules;
...
}
public class CourseSchedule implements Serializable {
private static final long serialVersionUID = -6645577819394287204L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
@ManyToOne
@JoinColumn(name = "instructor", nullable = true)
@JsonManagedReference
private Person instructor;
@ManyToOne
@JoinColumn(name = "outline", nullable = false)
@JsonIgnore
private CourseOutline outline;
...
}
в REST API. Я вызываю вызов списка CourseOutline по курсу, используяCourseOutline Repository:
List<CourseOutline> findAllByCourse(Course course);
, но я получаю ошибку ниже:
Could not write JSON: Infinite recursion (StackOverflowError); nested
exception is com.fasterxml.jackson.databind.JsonMappingException:
Infinite recursion (StackOverflowError) (through reference chain:
java.util.ArrayList[2]-myDomain.api.models.entities.CourseOutline[\"schedules\"])"