Ravi Srinivasan
2018-09-10 aaf094af7ecf98e07e31a231fdab871b25961bd1
commit | author | age
aaf094 1 package com.redhat.training.model;
RS 2
3 import javax.persistence.Entity;
4 import javax.persistence.Id;
5 import javax.persistence.NamedQuery;
6
7 @Entity
8 //add named query here
9 @NamedQuery(
10         name="getAllPersonsWithName",
11         query="select p from Person p where p.name = :pname")
12 public class Person{
13     @Id
14     private Long id;
15
16     private String name;
17
18     public Long getId() {
19         return id;
20     }
21
22     public void setId(Long id) {
23         this.id = id;
24     }
25
26     public String getName() {
27         return name;
28     }
29
30     public void setName(String name) {
31         this.name = name;
32     }
33
34     @Override
35     public int hashCode() {
36         final int prime = 31;
37         int result = 1;
38         result = prime * result + ((id == null) ? 0 : id.hashCode());
39         return result;
40     }
41
42     @Override
43     public boolean equals(Object obj) {
44         if (this == obj)
45             return true;
46         if (obj == null)
47             return false;
48         if (getClass() != obj.getClass())
49             return false;
50         Person other = (Person) obj;
51         if (id == null) {
52             if (other.id != null)
53                 return false;
54         } else if (!id.equals(other.id))
55             return false;
56         return true;
57     }
58
59     
60 }