Source code: org/hibernate/test/ejb3/fetch/Person.java
1 package org.hibernate.test.ejb3.fetch;
2
3 import java.io.Serializable;
4 import java.util.ArrayList;
5 import java.util.Collection;
6 import java.util.Date;
7
8 /**
9 * Copied over from annotations test suite...
10 *
11 * @author Emmanuel Bernard
12 */
13 public class Person implements Serializable {
14
15 // member declaration
16 private Long id;
17 private String firstName;
18 private String lastName;
19 private String companyName;
20 private Collection stays;
21 private Collection oldStays;
22 private Collection veryOldStays;
23
24 // constructors
25 public Person() {
26 }
27
28 public Person(String firstName, String lastName, String companyName) {
29 this.firstName = firstName;
30 this.lastName = lastName;
31 this.companyName = companyName;
32 }
33
34 public Long getId() {
35 return id;
36 }
37
38 public void setId(Long id) {
39 this.id = id;
40 }
41
42 public String getFirstName() {
43 return firstName;
44 }
45
46 public void setFirstName(String firstName) {
47 this.firstName = firstName;
48 }
49
50 public String getLastName() {
51 return lastName;
52 }
53
54 public void setLastName(String lastName) {
55 this.lastName = lastName;
56 }
57
58 public String getCompanyName() {
59 return companyName;
60 }
61
62 public void setCompanyName(String companyName) {
63 this.companyName = companyName;
64 }
65
66 public Collection getStays() {
67 return stays;
68 }
69
70 public void setStays(Collection stays) {
71 this.stays = stays;
72 }
73
74 public Collection getOldStays() {
75 return oldStays;
76 }
77
78 public void setOldStays(Collection oldStays) {
79 this.oldStays = oldStays;
80 }
81
82 public Collection getVeryOldStays() {
83 return veryOldStays;
84 }
85
86 public void setVeryOldStays(Collection veryOldStays) {
87 this.veryOldStays = veryOldStays;
88 }
89
90
91 // business logic
92 public void addStay(Date startDate, Date endDate, String vessel, String authoriser, String comments) {
93 Stay stay = new Stay( this, startDate, endDate, vessel, authoriser, comments );
94 addStay( stay );
95 }
96
97 public void addStay(Stay stay) {
98 Collection stays = getStays();
99 if ( stays == null ) {
100 stays = new ArrayList();
101 }
102 stays.add( stay );
103
104 this.stays = stays;
105 }
106
107 public void addOldStay(Date startDate, Date endDate, String vessel, String authoriser, String comments) {
108 Stay stay = new Stay( this, startDate, endDate, vessel, authoriser, comments );
109 addOldStay( stay );
110 }
111
112 public void addOldStay(Stay stay) {
113 Collection stays = getOldStays();
114 if ( stays == null ) {
115 stays = new ArrayList();
116 }
117 stays.add( stay );
118
119 this.oldStays = stays;
120 }
121
122 public void addVeryOldStay(Date startDate, Date endDate, String vessel, String authoriser, String comments) {
123 Stay stay = new Stay( this, startDate, endDate, vessel, authoriser, comments );
124 addVeryOldStay( stay );
125 }
126
127 public void addVeryOldStay(Stay stay) {
128 Collection stays = getVeryOldStays();
129 if ( stays == null ) {
130 stays = new ArrayList();
131 }
132 stays.add( stay );
133
134 this.veryOldStays = stays;
135 }
136 }
137