-
Notifications
You must be signed in to change notification settings - Fork 170
/
Copy pathRoleEntity.java
113 lines (89 loc) · 2.92 KB
/
RoleEntity.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
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
package org.ohdsi.webapi.shiro.Entities;
import java.io.Serializable;
import java.util.LinkedHashSet;
import java.util.Set;
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 org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
/**
* Created by GMalikov on 24.08.2015.
*/
@Entity(name = "RoleEntity")
@Table(name = "SEC_ROLE")
public class RoleEntity implements Serializable{
private static final long serialVersionUID = 6257846375334314942L;
@Id
@Column(name = "ID")
@GenericGenerator(
name = "sec_role_generator",
strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
parameters = {
@Parameter(name = "sequence_name", value = "sec_role_sequence"),
@Parameter(name = "initial_value", value = "1000"),
@Parameter(name = "increment_size", value = "1")
}
)
@GeneratedValue(generator = "sec_role_generator")
private Long id;
@Column(name = "NAME")
private String name;
@OneToMany(mappedBy = "role", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
private Set<RolePermissionEntity> rolePermissions = new LinkedHashSet<>();
@OneToMany(mappedBy = "role", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
private Set<UserRoleEntity> userRoles = new LinkedHashSet<>();
@Column(name = "system_role")
private Boolean systemRole;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<RolePermissionEntity> getRolePermissions() {
return rolePermissions;
}
public void setRolePermissions(Set<RolePermissionEntity> rolePermissions) {
this.rolePermissions = rolePermissions;
}
public Set<UserRoleEntity> getUserRoles() {
return userRoles;
}
public void setUserRoles(Set<UserRoleEntity> userRoles) {
this.userRoles = userRoles;
}
public Boolean isSystemRole() {
return systemRole;
}
public void setSystemRole(Boolean system) {
systemRole = system;
}
public void addRolePermissionEntity(RolePermissionEntity rolePermissionEntity) {
this.rolePermissions.add(rolePermissionEntity);
rolePermissionEntity.setRole(this);
}
public void removeRolePermissionEntity(RolePermissionEntity rolePermissionEntity) {
this.rolePermissions.remove(rolePermissionEntity);
rolePermissionEntity.setRole(null);
}
public void addUserRoleEntity(UserRoleEntity userRoleEntity) {
this.userRoles.add(userRoleEntity);
userRoleEntity.setRole(this);
}
public void removeUserRoleEntity(UserRoleEntity userRoleEntity) {
this.userRoles.remove(userRoleEntity);
userRoleEntity.setRole(null);
}
}