@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;
}
}
Run Code Online (Sandbox Code Playgroud)
我想初始化SalesT类的List <Map <Product,Integer >> listProduct属性,如何对其进行初始化?我尝试过这样
List<Map <Product, Integer>> listProduct = new ArrayList <HashMap <Product, Integer>>();
Run Code Online (Sandbox Code Playgroud)
但它不起作用。
谢谢。
java ×1