/
User.java
88 lines (73 loc) · 1.83 KB
/
User.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.kodilla.ecommercee.domain;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "USERS")
public class User {
private Long id;
private String username;
private String status;
private Long userKey;
private List<Order> orders = new ArrayList<>();
public User() {
}
public User(Long id, String username, String status, Long userKey) {
this.id = id;
this.username = username;
this.status = status;
this.userKey = userKey;
}
@Id
@NotNull
@GeneratedValue
public Long getId() {
return id;
}
@NotNull
@Column(name = "USERNAME")
public String getUsername() {
return username;
}
@NotNull
@Column(name = "STATUS")
public String getStatus() {
return status;
}
@Column(name = "USERKEY")
public Long getUserKey() {
return userKey;
}
@OneToMany(
targetEntity = Order.class,
mappedBy = "user",
cascade = CascadeType.ALL,
fetch = FetchType.LAZY
)
public List<Order> getOrders() {
return orders;
}
public void setId(Long id) {
this.id = id;
}
public void setUsername(String username) {
this.username = username;
}
public void setStatus(String status) {
this.status = status;
}
public void setUserKey(Long userKey) {
this.userKey = userKey;
}
public void setOrders(List<Order> orders) {
this.orders = orders;
}
}