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.kernel.common.apps;
020:
021: import java.io.Serializable;
022: import java.util.Date;
023: import java.util.HashSet;
024: import java.util.Locale;
025: import java.util.Set;
026: import javax.persistence.CascadeType;
027: import javax.persistence.Column;
028: import javax.persistence.Entity;
029: import javax.persistence.FetchType;
030: import javax.persistence.Id;
031: import javax.persistence.Inheritance;
032: import javax.persistence.InheritanceType;
033: import javax.persistence.OneToMany;
034: import javax.persistence.OneToOne;
035: import javax.persistence.Table;
036: import javax.persistence.Temporal;
037: import javax.persistence.TemporalType;
038: import javax.persistence.Transient;
039: import javax.persistence.Version;
040:
041: /**
042: * <p>Persitent type used in testing.</p>
043: *
044: * @author Abe White
045: */
046: @Entity
047: @Table(name="rtest1")
048: @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
049: public class RuntimeTest1 implements Serializable {
050:
051: private static final long serialVersionUID = 1L;
052:
053: @Temporal(TemporalType.DATE)
054: private Date dateField;
055:
056: @Transient
057: public static final String someStaticField = "someField";
058:
059: private Locale localeField;
060:
061: @Id
062: private int intField;
063:
064: private int intField1;
065:
066: @Column(length=35)
067: private String stringField;
068:
069: // transactional only
070: @Column(length=35)
071: public String transString;
072:
073: // relations
074: //@Transient
075: @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST,CascadeType.REMOVE})
076: private RuntimeTest1 selfOneOne;
077:
078: @OneToMany(mappedBy="selfOneOne",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
079: private Set<RuntimeTest1> selfOneMany = new HashSet<RuntimeTest1>();
080:
081: @Version
082: private int version;
083:
084: public RuntimeTest1() {
085: }
086:
087: public RuntimeTest1(int key) {
088: this .intField = key;
089: }
090:
091: public RuntimeTest1(String str, int i) {
092: stringField = str;
093: intField = i;
094: intField1 = i;
095: }
096:
097: public int getIntField() {
098: return this .intField;
099: }
100:
101: public int getIntField1() {
102: return this .intField1;
103: }
104:
105: public void setIntField(int intField) {
106: this .intField = intField;
107: }
108:
109: public void setIntField1(int intField1) {
110: this .intField1 = intField1;
111: }
112:
113: public String getStringField() {
114: return this .stringField;
115: }
116:
117: public void setStringField(String stringField) {
118: this .stringField = stringField;
119: }
120:
121: public RuntimeTest1 getSelfOneOne() {
122: return this .selfOneOne;
123: }
124:
125: public void setSelfOneOne(RuntimeTest1 selfOneOne) {
126: this .selfOneOne = selfOneOne;
127: }
128:
129: public Set getSelfOneMany() {
130: return this .selfOneMany;
131: }
132:
133: public void setSelfOneMany(Set selfOneMany) {
134: this .selfOneMany = selfOneMany;
135: }
136:
137: public String toString() {
138: return "IntField: " + intField + ", StringField: "
139: + stringField + " .";
140: }
141:
142: public Locale getLocaleField() {
143: return localeField;
144: }
145:
146: public void setLocaleField(Locale localeField) {
147: this .localeField = localeField;
148: }
149:
150: public Date getDateField() {
151: return this .dateField;
152: }
153:
154: public void setDateField(Date d) {
155: this.dateField = d;
156: }
157: }
|