|
39 | 39 | */
|
40 | 40 | package org.javaee7.batch.chunk.csv.database;
|
41 | 41 |
|
42 |
| -import java.io.Serializable; |
43 |
| -import javax.persistence.Basic; |
44 |
| -import javax.persistence.Column; |
45 |
| -import javax.persistence.Entity; |
46 |
| -import javax.persistence.GeneratedValue; |
47 |
| -import javax.persistence.GenerationType; |
48 |
| -import javax.persistence.Id; |
49 |
| -import javax.persistence.NamedQueries; |
50 |
| -import javax.persistence.NamedQuery; |
51 |
| -import javax.persistence.Table; |
| 42 | +import javax.persistence.*; |
52 | 43 | import javax.validation.constraints.NotNull;
|
53 | 44 | import javax.validation.constraints.Size;
|
54 | 45 | import javax.xml.bind.annotation.XmlRootElement;
|
| 46 | +import java.io.Serializable; |
55 | 47 |
|
56 | 48 | /**
|
57 | 49 | * @author Arun Gupta
|
|
66 | 58 | public class Person implements Serializable {
|
67 | 59 |
|
68 | 60 | @Id
|
69 |
| - @GeneratedValue(strategy = GenerationType.AUTO) |
70 | 61 | private int id;
|
71 | 62 |
|
72 | 63 | private static final long serialVersionUID = 1L;
|
@@ -94,6 +85,12 @@ public Person(String name, String hiredate) {
|
94 | 85 | this.hiredate = hiredate;
|
95 | 86 | }
|
96 | 87 |
|
| 88 | + public Person(int id, String name, String hiredate) { |
| 89 | + this.id = id; |
| 90 | + this.name = name; |
| 91 | + this.hiredate = hiredate; |
| 92 | + } |
| 93 | + |
97 | 94 | public int getId() {
|
98 | 95 | return id;
|
99 | 96 | }
|
@@ -132,15 +129,12 @@ public boolean equals(Object object) {
|
132 | 129 | return false;
|
133 | 130 | }
|
134 | 131 | Person other = (Person) object;
|
135 |
| - if ((this.name == null && other.name != null) || (this.name != null && !this.name.equals(other.name))) { |
136 |
| - return false; |
137 |
| - } |
138 |
| - return true; |
| 132 | + return !((this.name == null && other.name != null) || (this.name != null && !this.name.equals(other.name))); |
139 | 133 | }
|
140 | 134 |
|
141 | 135 | @Override
|
142 | 136 | public String toString() {
|
143 |
| - return name; |
| 137 | + return name + id; |
144 | 138 | }
|
145 | 139 |
|
146 | 140 | }
|
0 commit comments