1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.submitted.cglib_lazy_error;
17
18 public class Person {
19
20 private Long id;
21 private String firstName;
22 private String lastName;
23 private Person parent;
24
25 public Person getAncestor() {
26 if (getParent() == null) {
27 return this;
28 }
29 return getParent().getAncestor();
30 }
31
32 @Override
33 public boolean equals(Object o) {
34 if (this == o) {
35 return true;
36 }
37 if (!(o instanceof Person)) {
38 return false;
39 }
40
41 Person person = (Person) o;
42
43 if (id != null ? !id.equals(person.id) : person.id != null) {
44 return false;
45 }
46
47 return true;
48 }
49
50 @Override
51 public int hashCode() {
52 return id != null ? id.hashCode() : 0;
53 }
54
55 @Override
56 public String toString() {
57 return id + ": " + firstName + " " + lastName + " (" + parent + ")";
58 }
59
60 public String getFirstName() {
61 return firstName;
62 }
63
64 public void setFirstName(String firstName) {
65 this.firstName = firstName;
66 }
67
68 public String getLastName() {
69 return lastName;
70 }
71
72 public void setLastName(String lastName) {
73 this.lastName = lastName;
74 }
75
76 public Long getId() {
77 return id;
78 }
79
80 public void setId(Long id) {
81 this.id = id;
82 }
83
84 public Person getParent() {
85 return parent;
86 }
87
88 public void setParent(Person parent) {
89 this.parent = parent;
90 }
91 }