2 回答

TA貢獻(xiàn)1862條經(jīng)驗 獲得超6個贊
JPA 中默認(rèn)不加載相關(guān)實體。你必須在@ManyToMany 關(guān)系中定義fetch = FetchType.EAGER
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "project_gate_relation", joinColumns = @JoinColumn(name = "proj_id"), inverseJoinColumns = @JoinColumn(name = "gate_id"))
@JsonBackReference
private List<Gate> gates;
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "project_threshold_relation", joinColumns = @JoinColumn(name = "proj_id"), inverseJoinColumns = @JoinColumn(name = "thresholdgates_id"))
@JsonBackReference
private List<Threshold> thresholds;

TA貢獻(xiàn)2080條經(jīng)驗 獲得超4個贊
與 a 關(guān)聯(lián)的數(shù)據(jù)@ManyToMany
默認(rèn)是延遲加載的。您需要在急切加載中指定您想要的(如果您使用的是 spring-data,則可以使用實體圖)。
添加回答
舉報