我有以下关系 bw 下面给出的两个实体,当我从存储库中获取 OutletProductVariety 对象时,即使在使用 fetchtype Eager 之后,价格也会出现在 PersistentBag 中,而不是作为列表。
@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;
}
Run Code Online (Sandbox Code Playgroud)
和
@Entity
public class Price {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
Long Id;
@ManyToOne
@JoinColumn(name="outletVareityId")
private OutletProductVariety outletVariety;
private Double price;
}
Run Code Online (Sandbox Code Playgroud)
如何获得价格列表而不是 PersistentBag?