01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.openjpa.enhance;
20:
21: import java.io.Serializable;
22: import javax.persistence.Entity;
23: import javax.persistence.Version;
24: import javax.persistence.Id;
25: import javax.persistence.GeneratedValue;
26: import javax.persistence.Basic;
27: import javax.persistence.Inheritance;
28: import javax.persistence.InheritanceType;
29: import javax.persistence.Table;
30: import javax.persistence.FetchType;
31:
32: @Entity
33: @Table(name="UN_PROP")
34: @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
35: public class UnenhancedPropertyAccess implements UnenhancedType,
36: Serializable, Cloneable {
37:
38: private int id;
39: private int version;
40: private String sf = "foo";
41: private String lazyField = "lazy";
42:
43: @Id
44: @GeneratedValue
45: public int getId() {
46: return id;
47: }
48:
49: public void setId(int id) {
50: this .id = id;
51: }
52:
53: @Version
54: protected int getVersion() {
55: return version;
56: }
57:
58: protected void setVersion(int v) {
59: version = v;
60: }
61:
62: @Basic
63: public String getStringField() {
64: return sf;
65: }
66:
67: public void setStringField(String s) {
68: sf = s;
69: }
70:
71: @Basic(fetch=FetchType.LAZY)
72: public String getLazyField() {
73: return lazyField;
74: }
75:
76: public void setLazyField(String s) {
77: lazyField = s;
78: }
79:
80: public boolean equals(Object o) {
81: if (o == this )
82: return true;
83: if (o == null)
84: return false;
85: if (!getClass().isAssignableFrom(o.getClass()))
86: return false;
87:
88: return getId() == ((UnenhancedPropertyAccess) o).getId();
89: }
90:
91: public int hashCode() {
92: return getId();
93: }
94:
95: public Object clone() throws CloneNotSupportedException {
96: return super.clone();
97: }
98: }
|