1 package ejava.examples.blpurchase.bo;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import javax.persistence.Entity;
7 import javax.persistence.Id;
8 import javax.persistence.ManyToMany;
9 import javax.persistence.OneToOne;
10 import javax.persistence.PrimaryKeyJoinColumn;
11 import javax.persistence.Table;
12
13
14
15
16 @Entity
17 @Table(name="BLPURCHASE_CART")
18 public class Cart {
19 @Id
20 private String email;
21
22 @OneToOne
23 @PrimaryKeyJoinColumn(referencedColumnName="email")
24 private Account account;
25
26 @ManyToMany
27 private List<Product> products = new ArrayList<Product>();
28
29 public Cart(){}
30 public Cart(Account account) {
31 this.email=account.getEmail();
32 this.account=account;
33 }
34
35 public String getEmail() {
36 return email;
37 }
38 protected void setEmail(String email) {
39 this.email = email;
40 }
41
42 public Account getAccount() {
43 return account;
44 }
45
46 public void setAccount(Account account) {
47 this.account = account;
48 }
49
50 public List<Product> getProducts() {
51 return products;
52 }
53
54 public void setProducts(List<Product> products) {
55 this.products = products;
56 }
57 }