Ravi Srinivasan
2018-09-10 aaf094af7ecf98e07e31a231fdab871b25961bd1
commit | author | age
aaf094 1 package com.redhat.training.model;
RS 2
3 //add required libraries
4 import javax.persistence.Entity;
5 import javax.persistence.GeneratedValue;
6 import javax.persistence.GenerationType;
7 import javax.persistence.Id;
8 import javax.persistence.Column;
9
10 import java.io.Serializable;
11
12 //add @Entity annotation here
13 @Entity
14 public class Person implements Serializable{
15 //add annotations for primary key
16     @Id
17     @GeneratedValue(strategy = GenerationType.IDENTITY)
18     private Long id;
19
20 //add @Column(name="name") annotation to map column in database table
21     @Column(name="name")
22     private String personName;
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 getPersonName() {
33         return personName;
34     }
35
36     public void setName(String personName) {
37         this.personName = personName;
38     }
39
40     @Override
41     public int hashCode() {
42         final int prime = 31;
43         int result = 1;
44         result = prime * result + ((id == null) ? 0 : id.hashCode());
45         return result;
46     }
47
48     @Override
49     public boolean equals(Object obj) {
50         if (this == obj)
51             return true;
52         if (obj == null)
53             return false;
54         if (getClass() != obj.getClass())
55             return false;
56         Person other = (Person) obj;
57         if (id == null) {
58             if (other.id != null)
59                 return false;
60         } else if (!id.equals(other.id))
61             return false;
62         return true;
63     }
64
65     
66 }