-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployee.java
More file actions
161 lines (138 loc) · 4.22 KB
/
Employee.java
File metadata and controls
161 lines (138 loc) · 4.22 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package org.javaee7.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.NamedStoredProcedureQuery;
import javax.persistence.ParameterMode;
import javax.persistence.StoredProcedureParameter;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import org.javaee7.entity.listener.EmployeeEntityListener;
/**
*
* @author Juneau
*/
@Entity
@Table(name = "EMPLOYEE")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e"),
@NamedQuery(name = "Employee.findById", query = "SELECT e FROM Employee e WHERE e.id = :id"),
@NamedQuery(name = "Employee.findByFirst", query = "SELECT e FROM Employee e WHERE e.first = :first"),
@NamedQuery(name = "Employee.findByLast", query = "SELECT e FROM Employee e WHERE e.last = :last"),
@NamedQuery(name = "Employee.findByAge", query = "SELECT e FROM Employee e WHERE e.age = :age")})
@NamedStoredProcedureQuery(name="createEmp", procedureName="CREATE_EMP",
parameters = {
@StoredProcedureParameter(name="firstname", mode=ParameterMode.IN, type=String.class),
@StoredProcedureParameter(name="lastname", mode=ParameterMode.IN, type=String.class),
@StoredProcedureParameter(name="status", mode=ParameterMode.IN, type=String.class)
})
@EntityListeners(EmployeeEntityListener.class)
public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
// @Max(value=?) @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
@Id
@Basic(optional = false)
@NotNull
@Column(name = "ID")
private BigDecimal id;
@Size(max = 30)
@Column(name = "FIRSTNAME")
private String first;
@Size(max = 30)
@Column(name = "LASTNAME")
private String last;
@Column(name = "AGE")
private BigInteger age;
@ManyToOne(optional=false)
@JoinColumn(name="JOB_ID", nullable=false)
private Jobs job;
@Column(name= "STATUS")
private String status;
public Employee() {
}
public Employee(BigDecimal id) {
this.id = id;
}
public BigDecimal getId() {
return id;
}
public void setId(BigDecimal id) {
this.id = id;
}
public String getFirst() {
return first;
}
public void setFirst(String first) {
this.first = first;
}
public String getLast() {
return last;
}
public void setLast(String last) {
this.last = last;
}
public BigInteger getAge() {
return age;
}
public void setAge(BigInteger age) {
this.age = age;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Employee)) {
return false;
}
Employee other = (Employee) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "org.javaee7.entity.Employee[ id=" + id + " ]";
}
/**
* @return the status
*/
public String getStatus() {
return status;
}
/**
* @param status the status to set
*/
public void setStatus(String status) {
this.status = status;
}
/**
* @return the job
*/
public Jobs getJob() {
return job;
}
/**
* @param job the job to set
*/
public void setJob(Jobs job) {
this.job = job;
}
}