View Javadoc
1   /*
2    * Copyright 2002-2014 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.orm.jpa.domain;
18  
19  import javax.persistence.Basic;
20  import javax.persistence.CascadeType;
21  import javax.persistence.Entity;
22  import javax.persistence.FetchType;
23  import javax.persistence.GeneratedValue;
24  import javax.persistence.GenerationType;
25  import javax.persistence.Id;
26  import javax.persistence.JoinColumn;
27  import javax.persistence.OneToOne;
28  
29  import org.springframework.tests.sample.beans.TestBean;
30  
31  /**
32   * Simple JavaBean domain object representing an person.
33   *
34   * @author Rod Johnson
35   */
36  @Entity
37  public class Person {
38  
39  	@Id
40  	@GeneratedValue(strategy = GenerationType.AUTO)
41  	private Integer id;
42  
43  	private transient TestBean testBean;
44  
45  	// Lazy relationship to force use of instrumentation in JPA implementation.
46  	@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
47  	@JoinColumn(name = "DRIVERS_LICENSE_ID")
48  	private DriversLicense driversLicense;
49  
50  	private String first_name;
51  
52  	@Basic(fetch = FetchType.LAZY)
53  	private String last_name;
54  
55  
56  	public Integer getId() {
57  		return id;
58  	}
59  
60  	public void setTestBean(TestBean testBean) {
61  		this.testBean = testBean;
62  	}
63  
64  	public TestBean getTestBean() {
65  		return testBean;
66  	}
67  
68  	public void setFirstName(String firstName) {
69  		this.first_name = firstName;
70  	}
71  
72  	public String getFirstName() {
73  		return this.first_name;
74  	}
75  
76  	public void setLastName(String lastName) {
77  		this.last_name = lastName;
78  	}
79  
80  	public String getLastName() {
81  		return this.last_name;
82  	}
83  
84  	public void setDriversLicense(DriversLicense driversLicense) {
85  		this.driversLicense = driversLicense;
86  	}
87  
88  	public DriversLicense getDriversLicense() {
89  		return this.driversLicense;
90  	}
91  
92  	@Override
93  	public String toString() {
94  		return getClass().getName() + ":(" + hashCode() + ") id=" + id + "; firstName=" + first_name + "; lastName="
95  				+ last_name + "; testBean=" + testBean;
96  	}
97  
98  }