问题概述
@oneToMany与@ManyToOne 关联
"一" 方注解如下:
@OneToMany(mappedBy = "conDataInfo",cascade=CascadeType.ALL,fetch=FetchType.Lazy)
@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
private List<ThirdPartyInfo> thirdPartyInfo;
"多"方注解如下:
@ManyToOne
@JoinColumn(name = "systemCode")
private ConDataInfo conDataInfo;
"一"方中共有三个与"多"方的关联关系.
在这种情况下,查询时报:failed to lazily initialize a collection of role
解决方案
将接收类型List改为Set
经测试,查询功能正常.