-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathRole.java
69 lines (56 loc) · 1.38 KB
/
Role.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
package com.lambdaschool.usermodel.models;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.validator.constraints.EAN;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "roles")
public class Role extends Auditable
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long roleid;
@Column(nullable = false,
unique = true)
private String name;
@OneToMany(mappedBy = "role",
cascade = CascadeType.ALL)
@JsonIgnoreProperties("role")
private List<UserRoles> userroles = new ArrayList<>();
public Role()
{
}
public Role(String name)
{
this.name = name.toUpperCase();
}
public long getRoleid()
{
return roleid;
}
public void setRoleid(long roleid)
{
this.roleid = roleid;
}
public String getName()
{
if (name == null) // possible to not have a name when doing an update, so check is neccessary
{
return null;
} else
{
return name.toUpperCase();
}
}
public void setName(String name)
{
this.name = name.toUpperCase();
}
public List<UserRoles> getUserroles() {
return userroles;
}
public void setUserroles(List<UserRoles> userroles) {
this.userroles = userroles;
}
}