how to solve could not write json 3a infinite recursion 28stackoverflowerror 29

Solutions on MaxInterview for how to solve could not write json 3a infinite recursion 28stackoverflowerror 29 by the best coders in the world

showing results for - "how to solve could not write json 3a infinite recursion 28stackoverflowerror 29"
Jakob
27 Aug 2016
1// Business Object 1:
2
3@Entity
4@Table(name = "ta_trainee", uniqueConstraints = {@UniqueConstraint(columnNames = {"id"})})
5public class Trainee extends BusinessObject {
6
7    @OneToMany(mappedBy = "trainee", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
8    @Column(nullable = true)
9    @JsonManagedReference
10    private Set<BodyStat> bodyStats;
11
12// Business Object 2:
13
14@Entity
15@Table(name = "ta_bodystat", uniqueConstraints = {@UniqueConstraint(columnNames = {"id"})})
16public class BodyStat extends BusinessObject {
17
18    @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
19    @JoinColumn(name="trainee_fk")
20    @JsonBackReference
21    private Trainee trainee;