我有以下两个实体之间的关系。当我从仓库获取OutletProductVariety对象时,即使使用了Eager fetchtype,价格仍以PersistentBag的形式而不是List的形式呈现。
@Entity
public class OutletProductVariety {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Long id;
@ManyToOne
@JoinColumn(name = "varietyId")
Variety variety;
@OneToMany(mappedBy = "outletVariety", fetch = FetchType.EAGER)
List<Price> price;
}
并且
@Entity
public class Price {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
Long Id;
@ManyToOne
@JoinColumn(name="outletVareityId")
private OutletProductVariety outletVariety;
private Double price;
}
如何获取价格列表而不是PersistentBag?