@Entity
public class SalesT {
@Id
@GeneratedValue
private int id;
@OneToOne
private Customer customer;
@OneToMany(targetEntity = Product.class)
private List< Map<Product,Integer> > listProduct;// I want to intialize this
public SalesT() {
}
public SalesT(Customer customer, List<Map<Product, Integer>> product) {
this.customer = customer;
this.listProduct = product;
}
}
我想初始化列表<地圖<產品地圖,整數>> listProduct的SalesT類的屬性,如何初始化?我試過像這樣如何初始化Java集合列表內
List<Map <Product, Integer>> listProduct = new ArrayList <HashMap <Product, Integer>>();
但它不工作。
謝謝。