如果我在我的項目冬眠 - 不負載的渴望協會懶實體
@Entity
@Table(name = "application_home_screen")
public class ApplicationHomeScreenVO implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Integer id;
@OneToOne(fetch = FetchType.EAGER)
@Cascade({ CascadeType.ALL })
@JoinColumn(name="image1_id")
private ApplicationImageVO image1;
@OneToOne(fetch = FetchType.EAGER)
@Cascade({ CascadeType.ALL })
@JoinColumn(name="image2_id")
private ApplicationImageVO image2;
}
@Entity
@Table(name = "application_image")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class ApplicationImageVO implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Integer id;
@OneToOne(fetch = FetchType.LAZY, mappedBy = "image1")
@Cascade({ CascadeType.ALL })
private ApplicationHomeScreenVO homeScreenImage1;
@OneToOne(fetch = FetchType.LAZY, mappedBy = "image2")
@Cascade({ CascadeType.ALL })
private ApplicationHomeScreenVO homeScreenImage2;
@OneToOne(fetch = FetchType.LAZY, mappedBy = "otherEntity1")
@Cascade({ CascadeType.ALL })
private OtherEntity1 otherEntity1;
@OneToOne(fetch = FetchType.LAZY, mappedBy = "otherEntity2")
@Cascade({ CascadeType.ALL })
private OtherEntity2 otherEntity2;
@OneToOne(fetch = FetchType.LAZY, mappedBy = "otherEntity3")
@Cascade({ CascadeType.ALL })
private OtherEntity3 otherEntity3;
@OneToOne(fetch = FetchType.LAZY, mappedBy = "otherEntity4")
@Cascade({ CascadeType.ALL })
private OtherEntity4 otherEntity3;
}
以下類當我加載ApplicationHomeVO - ID只期望圖像1和圖像2被從ApplicationImageVO類但加載情況並非如此
ApplicationImageVO類中的所有其他對象也會加載,即使它們標記爲LAZY。我預計只有ApplicationHomeScreenVO對象被加載
有什麼辦法阻止這些其他entites被加載?
謝謝 Damie
「所有的其他圖像對象也加載即使它們被標記爲懶人」有沒有您發佈的代碼中的其他圖像對象。 – Tunaki
道歉 - 更新了帖子 –