Ravi Srinivasan
2018-09-10 41d5004b9e40b9e29b37c26cbd1c154b97e2fe7a
commit | author | age
41d500 1 package com.redhat.training.model;
RS 2
3 import java.util.Set;
4
5 import javax.persistence.Entity;
6 import javax.persistence.FetchType;
7 import javax.persistence.GeneratedValue;
8 import javax.persistence.GenerationType;
9 import javax.persistence.Id;
10 import javax.persistence.OneToMany;
11
12 @Entity
13 public class UserGroup {
14
15     @Id
16     @GeneratedValue(strategy = GenerationType.IDENTITY)
17     private Long id;
18
19     private String name;
20
21     @OneToMany(mappedBy="userGroup", fetch=FetchType.LAZY)
22     private Set<User> users;
23
24     public Long getId() {
25         return id;
26     }
27
28     public void setId(Long id) {
29         this.id = id;
30     }
31
32     public String getName() {
33         return name;
34     }
35
36     public void setName(String name) {
37         this.name = name;
38     }
39
40     public Set<User> getUsers() {
41         return users;
42     }
43
44     public void setUsers(Set<User> users) {
45         this.users = users;
46     }
47
48     @Override
49     public int hashCode() {
50         final int prime = 31;
51         int result = 1;
52         result = prime * result + ((id == null) ? 0 : id.hashCode());
53         return result;
54     }
55
56     @Override
57     public boolean equals(Object obj) {
58         if (this == obj)
59             return true;
60         if (obj == null)
61             return false;
62         if (getClass() != obj.getClass())
63             return false;
64         UserGroup other = (UserGroup) obj;
65         if (id == null) {
66             if (other.id != null)
67                 return false;
68         } else if (!id.equals(other.id))
69             return false;
70         return true;
71     }
72
73     @Override
74     public String toString() {
75         return "UserGroup     [id=" + id + ", name=" + name + "]";
76     }
77
78 }