In a rest application, I use spring boot with jpa.
I have a class Lodger
who have
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, m
Solution:
Use
@JsonManagedReference
annotation for the first objects instantiated
@JsonBackReference
annotation for the second objects instantiated
First:
@JsonManagedReference
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "lodger")
private List referenceList;
Second:
@JsonBackReference
@ManyToOne
@JoinColumn(name = "lodgerId")
private Lodger lodger;