001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.openejb.jee.jpa;
017:
018: import java.util.ArrayList;
019: import java.util.List;
020: import javax.xml.bind.annotation.XmlAccessType;
021: import javax.xml.bind.annotation.XmlAccessorType;
022: import javax.xml.bind.annotation.XmlAttribute;
023: import javax.xml.bind.annotation.XmlElement;
024: import javax.xml.bind.annotation.XmlType;
025: import javax.xml.bind.annotation.XmlTransient;
026:
027: /**
028: *
029: *
030: * @Target({METHOD, FIELD}) @Retention(RUNTIME)
031: * public @interface OneToOne {
032: * Class targetEntity() default void.class;
033: * CascadeType[] cascade() default {};
034: * FetchType fetch() default EAGER;
035: * boolean optional() default true;
036: * String mappedBy() default "";
037: * }
038: *
039: *
040: *
041: * <p>Java class for one-to-one complex type.
042: *
043: * <p>The following schema fragment specifies the expected content contained within this class.
044: *
045: * <pre>
046: * <complexType name="one-to-one">
047: * <complexContent>
048: * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
049: * <sequence>
050: * <choice>
051: * <element name="primary-key-join-column" type="{http://java.sun.com/xml/ns/persistence/orm}primary-key-join-column" maxOccurs="unbounded" minOccurs="0"/>
052: * <element name="join-column" type="{http://java.sun.com/xml/ns/persistence/orm}join-column" maxOccurs="unbounded" minOccurs="0"/>
053: * <element name="join-table" type="{http://java.sun.com/xml/ns/persistence/orm}join-table" minOccurs="0"/>
054: * </choice>
055: * <element name="cascade" type="{http://java.sun.com/xml/ns/persistence/orm}cascade-type" minOccurs="0"/>
056: * </sequence>
057: * <attribute name="fetch" type="{http://java.sun.com/xml/ns/persistence/orm}fetch-type" />
058: * <attribute name="mapped-by" type="{http://www.w3.org/2001/XMLSchema}string" />
059: * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
060: * <attribute name="optional" type="{http://www.w3.org/2001/XMLSchema}boolean" />
061: * <attribute name="target-entity" type="{http://www.w3.org/2001/XMLSchema}string" />
062: * </restriction>
063: * </complexContent>
064: * </complexType>
065: * </pre>
066: *
067: *
068: */
069: @XmlAccessorType(XmlAccessType.FIELD)
070: @XmlType(name="one-to-one",propOrder={"primaryKeyJoinColumn","joinColumn","joinTable","cascade"})
071: public class OneToOne implements RelationField {
072:
073: @XmlElement(name="primary-key-join-column")
074: protected List<PrimaryKeyJoinColumn> primaryKeyJoinColumn;
075: @XmlElement(name="join-column")
076: protected List<JoinColumn> joinColumn;
077: @XmlElement(name="join-table")
078: protected JoinTable joinTable;
079: protected CascadeType cascade;
080: @XmlAttribute
081: protected FetchType fetch;
082: @XmlAttribute(name="mapped-by")
083: protected String mappedBy;
084: @XmlAttribute(required=true)
085: protected String name;
086: @XmlAttribute
087: protected Boolean optional;
088: @XmlAttribute(name="target-entity")
089: protected String targetEntity;
090: @XmlTransient
091: protected RelationField relatedField;
092: @XmlTransient
093: protected boolean syntheticField;
094:
095: /**
096: * Gets the value of the primaryKeyJoinColumn property.
097: *
098: * <p>
099: * This accessor method returns a reference to the live list,
100: * not a snapshot. Therefore any modification you make to the
101: * returned list will be present inside the JAXB object.
102: * This is why there is not a <CODE>set</CODE> method for the primaryKeyJoinColumn property.
103: *
104: * <p>
105: * For example, to add a new item, do as follows:
106: * <pre>
107: * getPrimaryKeyJoinColumn().add(newItem);
108: * </pre>
109: *
110: *
111: * <p>
112: * Objects of the following type(s) are allowed in the list
113: * {@link PrimaryKeyJoinColumn }
114: *
115: *
116: */
117: public List<PrimaryKeyJoinColumn> getPrimaryKeyJoinColumn() {
118: if (primaryKeyJoinColumn == null) {
119: primaryKeyJoinColumn = new ArrayList<PrimaryKeyJoinColumn>();
120: }
121: return this .primaryKeyJoinColumn;
122: }
123:
124: /**
125: * Gets the value of the joinColumn property.
126: *
127: * <p>
128: * This accessor method returns a reference to the live list,
129: * not a snapshot. Therefore any modification you make to the
130: * returned list will be present inside the JAXB object.
131: * This is why there is not a <CODE>set</CODE> method for the joinColumn property.
132: *
133: * <p>
134: * For example, to add a new item, do as follows:
135: * <pre>
136: * getJoinColumn().add(newItem);
137: * </pre>
138: *
139: *
140: * <p>
141: * Objects of the following type(s) are allowed in the list
142: * {@link JoinColumn }
143: *
144: *
145: */
146: public List<JoinColumn> getJoinColumn() {
147: if (joinColumn == null) {
148: joinColumn = new ArrayList<JoinColumn>();
149: }
150: return this .joinColumn;
151: }
152:
153: /**
154: * Gets the value of the joinTable property.
155: *
156: * @return
157: * possible object is
158: * {@link JoinTable }
159: *
160: */
161: public JoinTable getJoinTable() {
162: return joinTable;
163: }
164:
165: /**
166: * Sets the value of the joinTable property.
167: *
168: * @param value
169: * allowed object is
170: * {@link JoinTable }
171: *
172: */
173: public void setJoinTable(JoinTable value) {
174: this .joinTable = value;
175: }
176:
177: /**
178: * Gets the value of the cascade property.
179: *
180: * @return
181: * possible object is
182: * {@link CascadeType }
183: *
184: */
185: public CascadeType getCascade() {
186: return cascade;
187: }
188:
189: /**
190: * Sets the value of the cascade property.
191: *
192: * @param value
193: * allowed object is
194: * {@link CascadeType }
195: *
196: */
197: public void setCascade(CascadeType value) {
198: this .cascade = value;
199: }
200:
201: /**
202: * Gets the value of the fetch property.
203: *
204: * @return
205: * possible object is
206: * {@link FetchType }
207: *
208: */
209: public FetchType getFetch() {
210: return fetch;
211: }
212:
213: /**
214: * Sets the value of the fetch property.
215: *
216: * @param value
217: * allowed object is
218: * {@link FetchType }
219: *
220: */
221: public void setFetch(FetchType value) {
222: this .fetch = value;
223: }
224:
225: /**
226: * Gets the value of the mappedBy property.
227: *
228: * @return
229: * possible object is
230: * {@link String }
231: *
232: */
233: public String getMappedBy() {
234: return mappedBy;
235: }
236:
237: /**
238: * Sets the value of the mappedBy property.
239: *
240: * @param value
241: * allowed object is
242: * {@link String }
243: *
244: */
245: public void setMappedBy(String value) {
246: this .mappedBy = value;
247: }
248:
249: /**
250: * Gets the value of the name property.
251: *
252: * @return
253: * possible object is
254: * {@link String }
255: *
256: */
257: public String getName() {
258: return name;
259: }
260:
261: /**
262: * Sets the value of the name property.
263: *
264: * @param value
265: * allowed object is
266: * {@link String }
267: *
268: */
269: public void setName(String value) {
270: this .name = value;
271: }
272:
273: /**
274: * Gets the value of the optional property.
275: *
276: * @return
277: * possible object is
278: * {@link Boolean }
279: *
280: */
281: public Boolean isOptional() {
282: return optional;
283: }
284:
285: /**
286: * Sets the value of the optional property.
287: *
288: * @param value
289: * allowed object is
290: * {@link Boolean }
291: *
292: */
293: public void setOptional(Boolean value) {
294: this .optional = value;
295: }
296:
297: /**
298: * Gets the value of the targetEntity property.
299: *
300: * @return
301: * possible object is
302: * {@link String }
303: *
304: */
305: public String getTargetEntity() {
306: return targetEntity;
307: }
308:
309: /**
310: * Sets the value of the targetEntity property.
311: *
312: * @param value
313: * allowed object is
314: * {@link String }
315: *
316: */
317: public void setTargetEntity(String value) {
318: this .targetEntity = value;
319: }
320:
321: /**
322: * This is only used for xml converters and will normally return null.
323: * Gets the field on the target entity for this relationship.
324: * @return the field on the target entity for this relationship.
325: */
326: public RelationField getRelatedField() {
327: return relatedField;
328: }
329:
330: /**
331: * Gets the field on the target entity for this relationship.
332: * @param value field on the target entity for this relationship.
333: */
334: public void setRelatedField(RelationField value) {
335: this .relatedField = value;
336: }
337:
338: public boolean isSyntheticField() {
339: return syntheticField;
340: }
341:
342: public void setSyntheticField(boolean syntheticField) {
343: this.syntheticField = syntheticField;
344: }
345: }
|