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