001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype;
020:
021: import java.util.*;
022:
023: import javax.persistence.*;
024:
025: import org.apache.openjpa.persistence.jdbc.*;
026:
027: @Entity
028: @Table(name="ANNOTEST1")
029: @Inheritance(strategy=InheritanceType.JOINED)
030: @DiscriminatorColumn(name="ANNOCLS")
031: @DiscriminatorValue("ANNO1")
032: @SecondaryTables({@SecondaryTable(name="OTHER_ANNOTEST1",pkJoinColumns=@PrimaryKeyJoinColumn(name="OTHER_PK",referencedColumnName="PK"))})
033: public class AnnoTest1 {
034:
035: @Id
036: @Column(name="PK")
037: private Long pk;
038:
039: @Version
040: @Column(name="ANNOVER")
041: private int version;
042:
043: @Basic
044: private int basic;
045:
046: @Transient
047: private int trans;
048:
049: @Basic
050: @Column(name="OTHERVALUE",table="OTHER_ANNOTEST1")
051: private int otherTableBasic;
052:
053: @OneToOne(fetch=FetchType.LAZY)
054: @JoinColumn(name="SELFONEONE_PK",referencedColumnName="PK")
055: private AnnoTest1 selfOneOne;
056:
057: @OneToOne
058: @PrimaryKeyJoinColumn
059: private AnnoTest1 pkJoinSelfOneOne;
060:
061: @OneToOne
062: @JoinColumns({@JoinColumn(name="ONEONE_PK1",referencedColumnName="PK1"),@JoinColumn(name="ONEONE_PK2",referencedColumnName="PK2")})
063: private AnnoTest2 oneOne;
064:
065: @OneToOne(fetch=FetchType.LAZY)
066: @JoinColumns({@JoinColumn(name="OTHERONE_PK1",referencedColumnName="PK1",table="OTHER_ANNOTEST1"),@JoinColumn(name="OTHERONE_PK2",referencedColumnName="PK2",table="OTHER_ANNOTEST1")})
067: private AnnoTest2 otherTableOneOne;
068:
069: @OneToOne(mappedBy="inverseOneOne",fetch=FetchType.LAZY)
070: private AnnoTest2 inverseOwnerOneOne;
071:
072: @Lob
073: @Column(name="BLOBVAL")
074: private byte[] blob;
075:
076: @Basic
077: @Lob
078: @Column(name="SERVAL")
079: private Object serial;
080:
081: @Column(name="CLOBVAL")
082: @Lob
083: private String clob;
084:
085: // un-annotated enum should be persisted by default
086: @Column(name="ENUMVAL")
087: private InheritanceType enumeration;
088:
089: @Enumerated
090: @Column(name="ORD_ENUMVAL")
091: private InheritanceType ordinalEnumeration;
092:
093: @Enumerated(EnumType.STRING)
094: @Column(name="STR_ENUMVAL")
095: private InheritanceType stringEnumeration;
096:
097: @OneToMany
098: @ElementJoinColumn(name="ONEMANY_PK",referencedColumnName="PK")
099: private Set<AnnoTest2> oneMany = new HashSet();
100:
101: @OneToMany(mappedBy="oneManyOwner")
102: private Set<AnnoTest2> inverseOwnerOneMany = new HashSet();
103:
104: @ManyToMany
105: @JoinTable(name="ANNOTEST1_MANYMANY",joinColumns=@JoinColumn(name="MANY_PK"),inverseJoinColumns={@JoinColumn(name="MANY_PK1",referencedColumnName="PK1"),@JoinColumn(name="MANY_PK2",referencedColumnName="PK2")})
106: private Set<AnnoTest2> manyMany = new HashSet();
107:
108: @ManyToMany(mappedBy="manyMany")
109: private Set<AnnoTest2> inverseOwnerManyMany = new HashSet();
110:
111: @MapKey
112: @OneToMany
113: private Map<Integer, Flat1> defaultMapKey = new HashMap();
114:
115: @MapKey(name="basic")
116: @OneToMany
117: private Map<Integer, Flat1> namedMapKey = new HashMap();
118:
119: @MapKey(name="basic")
120: @OneToMany(mappedBy="oneManyOwner")
121: private Map<String, AnnoTest2> inverseOwnerMapKey = new HashMap();
122:
123: public AnnoTest1() {
124: }
125:
126: public AnnoTest1(long pk) {
127: this .pk = new Long(pk);
128: }
129:
130: // public AnnoTest1(Long pk) {
131: // this.pk = pk;
132: // }
133:
134: public void setPk(Long val) {
135: pk = val;
136: }
137:
138: public Long getPk() {
139: return pk;
140: }
141:
142: public int getVersion() {
143: return version;
144: }
145:
146: public void setBasic(int i) {
147: basic = i;
148: }
149:
150: public int getBasic() {
151: return basic;
152: }
153:
154: public void setTransient(int i) {
155: trans = i;
156: }
157:
158: public int getTransient() {
159: return trans;
160: }
161:
162: public void setOtherTableBasic(int i) {
163: otherTableBasic = i;
164: }
165:
166: public int getOtherTableBasic() {
167: return otherTableBasic;
168: }
169:
170: public void setSelfOneOne(AnnoTest1 other) {
171: selfOneOne = other;
172: }
173:
174: public AnnoTest1 getSelfOneOne() {
175: return selfOneOne;
176: }
177:
178: public void setPKJoinSelfOneOne(AnnoTest1 other) {
179: pkJoinSelfOneOne = other;
180: }
181:
182: public AnnoTest1 getPKJoinSelfOneOne() {
183: return pkJoinSelfOneOne;
184: }
185:
186: public void setOneOne(AnnoTest2 other) {
187: oneOne = other;
188: }
189:
190: public AnnoTest2 getOneOne() {
191: return oneOne;
192: }
193:
194: public void setOtherTableOneOne(AnnoTest2 other) {
195: otherTableOneOne = other;
196: }
197:
198: public AnnoTest2 getOtherTableOneOne() {
199: return otherTableOneOne;
200: }
201:
202: public void setInverseOwnerOneOne(AnnoTest2 other) {
203: inverseOwnerOneOne = other;
204: }
205:
206: public AnnoTest2 getInverseOwnerOneOne() {
207: return inverseOwnerOneOne;
208: }
209:
210: public void setBlob(byte[] bytes) {
211: blob = bytes;
212: }
213:
214: public byte[] getBlob() {
215: return blob;
216: }
217:
218: public void setSerialized(Object o) {
219: serial = o;
220: }
221:
222: public Object getSerialized() {
223: return serial;
224: }
225:
226: public void setClob(String s) {
227: clob = s;
228: }
229:
230: public String getClob() {
231: return clob;
232: }
233:
234: public InheritanceType getEnumeration() {
235: return enumeration;
236: }
237:
238: public void setEnumeration(InheritanceType val) {
239: enumeration = val;
240: }
241:
242: public InheritanceType getOrdinalEnumeration() {
243: return ordinalEnumeration;
244: }
245:
246: public void setOrdinalEnumeration(InheritanceType val) {
247: ordinalEnumeration = val;
248: }
249:
250: public InheritanceType getStringEnumeration() {
251: return stringEnumeration;
252: }
253:
254: public void setStringEnumeration(InheritanceType val) {
255: stringEnumeration = val;
256: }
257:
258: public Set<AnnoTest2> getOneMany() {
259: return oneMany;
260: }
261:
262: public Set<AnnoTest2> getInverseOwnerOneMany() {
263: return inverseOwnerOneMany;
264: }
265:
266: public Set<AnnoTest2> getManyMany() {
267: return manyMany;
268: }
269:
270: public Set<AnnoTest2> getInverseOwnerManyMany() {
271: return inverseOwnerManyMany;
272: }
273:
274: public Map<Integer, Flat1> getDefaultMapKey() {
275: return this .defaultMapKey;
276: }
277:
278: public void setDefaultMapKey(Map<Integer, Flat1> defaultMapKey) {
279: this .defaultMapKey = defaultMapKey;
280: }
281:
282: public Map<Integer, Flat1> getNamedMapKey() {
283: return this .namedMapKey;
284: }
285:
286: public void setNamedMapKey(Map<Integer, Flat1> namedMapKey) {
287: this .namedMapKey = namedMapKey;
288: }
289:
290: public Map<String, AnnoTest2> getInverseOwnerMapKey() {
291: return this .inverseOwnerMapKey;
292: }
293:
294: public void setInverseOwnerMapKey(
295: Map<String, AnnoTest2> inverseOwnerMapKey) {
296: this.inverseOwnerMapKey = inverseOwnerMapKey;
297: }
298: }
|