1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.shiro.samples.sprhib.model; |
20 | |
|
21 | |
import org.hibernate.annotations.Cache; |
22 | |
import org.hibernate.annotations.CacheConcurrencyStrategy; |
23 | |
import org.hibernate.annotations.CollectionOfElements; |
24 | |
import org.hibernate.annotations.Index; |
25 | |
|
26 | |
import javax.persistence.*; |
27 | |
import java.util.Set; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
@Entity |
33 | |
@Table(name="roles") |
34 | |
@Cache(usage= CacheConcurrencyStrategy.READ_WRITE) |
35 | |
public class Role { |
36 | |
|
37 | |
private Long id; |
38 | |
|
39 | |
private String name; |
40 | |
|
41 | |
private String description; |
42 | |
|
43 | |
private Set<String> permissions; |
44 | |
|
45 | 0 | protected Role() { |
46 | 0 | } |
47 | |
|
48 | 0 | public Role(String name) { |
49 | 0 | this.name = name; |
50 | 0 | } |
51 | |
|
52 | |
|
53 | |
@Id |
54 | |
@GeneratedValue |
55 | |
public Long getId() { |
56 | 0 | return id; |
57 | |
} |
58 | |
|
59 | |
public void setId(Long id) { |
60 | 0 | this.id = id; |
61 | 0 | } |
62 | |
|
63 | |
@Basic(optional=false) |
64 | |
@Column(length=100) |
65 | |
@Index(name="idx_roles_name") |
66 | |
public String getName() { |
67 | 0 | return name; |
68 | |
} |
69 | |
|
70 | |
public void setName(String name) { |
71 | 0 | this.name = name; |
72 | 0 | } |
73 | |
|
74 | |
@Basic(optional=false) |
75 | |
@Column(length=255) |
76 | |
public String getDescription() { |
77 | 0 | return description; |
78 | |
} |
79 | |
|
80 | |
public void setDescription(String description) { |
81 | 0 | this.description = description; |
82 | 0 | } |
83 | |
|
84 | |
@CollectionOfElements |
85 | |
@JoinTable(name="roles_permissions") |
86 | |
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE) |
87 | |
public Set<String> getPermissions() { |
88 | 0 | return permissions; |
89 | |
} |
90 | |
|
91 | |
public void setPermissions(Set<String> permissions) { |
92 | 0 | this.permissions = permissions; |
93 | 0 | } |
94 | |
|
95 | |
} |
96 | |
|
97 | |
|