我在下面制作了一些域名。
> VM188:30554 WARNING: Tried to load angular more than once.
我制作了像下面的代码一样的freemarker。
@Entity
public class Conference {
...
@OneToMany(
targetEntity = ProgramDate.class,
mappedBy = "conference",
cascade = CascadeType.REMOVE,
fetch = FetchType.EAGER
)
@JsonBackReference
private List<ProgramDate> programDateList;
}
@Entity
public class Program {
...
@ManyToOne
@JoinColumn(name = "program_date_id")
@JsonBackReference
private ProgramDate date;
@ManyToOne
@JoinColumn(name = "room_id")
private Room room;
...
}
@Entity
public class ProgramDate {
...
@OneToMany(
targetEntity = Program.class,
mappedBy = "date",
fetch = FetchType.EAGER
)
@JsonBackReference
private List<Program> programList;
@ManyToOne
@JoinColumn(name = "conference_id")
private Conference conference;
}
@Entity
public class Room {
...
@OneToMany(
targetEntity = Program.class,
mappedBy = "room",
fetch = FetchType.EAGER
)
@JsonBackReference
private List<Program> programList;
}
我遇到的问题是JPA OneToMany,ManyToOne Relationship的无限递归引用。我尝试添加 <#list conference.programDateList as date>
...
</#list>
,但它只解决了json递归问题。
答案 0 :(得分:1)
使用json忽略注释:
@OneToMany(
targetEntity = Program.class,
mappedBy = "date",
fetch = FetchType.EAGER
)
@JsonIgnore
private List<Program> programList;
答案 1 :(得分:0)
为什么要包括Room&amp;参加大会的计划,然后在计划中添加会议室和会议室。一个应该已经包含在会议中的计划日期?然后在ProgramDate中你有另一个对...会议和程序列表的引用......
基本上你不应该尝试用一些花哨的注释来“破解”这些循环,但你应该处理你的数据模型。会议看起来还不错,计划可能只是一个会议清单,计划日期应该是......约会。