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 OneToMany {
032: * Class targetEntity() default void.class;
033: * CascadeType[] cascade() default {};
034: * FetchType fetch() default LAZY;
035: * String mappedBy() default "";
036: * }
037: *
038: *
039: *
040: * <p>Java class for one-to-many complex type.
041: *
042: * <p>The following schema fragment specifies the expected content contained within this class.
043: *
044: * <pre>
045: * <complexType name="one-to-many">
046: * <complexContent>
047: * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
048: * <sequence>
049: * <element name="order-by" type="{http://java.sun.com/xml/ns/persistence/orm}order-by" minOccurs="0"/>
050: * <element name="map-key" type="{http://java.sun.com/xml/ns/persistence/orm}map-key" minOccurs="0"/>
051: * <choice>
052: * <element name="join-table" type="{http://java.sun.com/xml/ns/persistence/orm}join-table" minOccurs="0"/>
053: * <element name="join-column" type="{http://java.sun.com/xml/ns/persistence/orm}join-column" maxOccurs="unbounded" 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="target-entity" type="{http://www.w3.org/2001/XMLSchema}string" />
061: * </restriction>
062: * </complexContent>
063: * </complexType>
064: * </pre>
065: *
066: *
067: */
068: @XmlAccessorType(XmlAccessType.FIELD)
069: @XmlType(name="one-to-many",propOrder={"orderBy","mapKey","joinTable","joinColumn","cascade"})
070: public class OneToMany implements RelationField {
071:
072: @XmlElement(name="order-by")
073: protected String orderBy;
074: @XmlElement(name="map-key")
075: protected MapKey mapKey;
076: @XmlElement(name="join-table")
077: protected JoinTable joinTable;
078: @XmlElement(name="join-column")
079: protected List<JoinColumn> joinColumn;
080: protected CascadeType cascade;
081: @XmlAttribute
082: protected FetchType fetch;
083: @XmlAttribute(name="mapped-by")
084: protected String mappedBy;
085: @XmlAttribute(required=true)
086: protected String name;
087: @XmlAttribute(name="target-entity")
088: protected String targetEntity;
089: @XmlTransient
090: protected RelationField relatedField;
091: @XmlTransient
092: protected boolean syntheticField;
093:
094: /**
095: * Gets the value of the orderBy property.
096: *
097: * @return
098: * possible object is
099: * {@link String }
100: *
101: */
102: public String getOrderBy() {
103: return orderBy;
104: }
105:
106: /**
107: * Sets the value of the orderBy property.
108: *
109: * @param value
110: * allowed object is
111: * {@link String }
112: *
113: */
114: public void setOrderBy(String value) {
115: this .orderBy = value;
116: }
117:
118: /**
119: * Gets the value of the mapKey property.
120: *
121: * @return
122: * possible object is
123: * {@link MapKey }
124: *
125: */
126: public MapKey getMapKey() {
127: return mapKey;
128: }
129:
130: /**
131: * Sets the value of the mapKey property.
132: *
133: * @param value
134: * allowed object is
135: * {@link MapKey }
136: *
137: */
138: public void setMapKey(MapKey value) {
139: this .mapKey = value;
140: }
141:
142: /**
143: * Gets the value of the joinTable property.
144: *
145: * @return
146: * possible object is
147: * {@link JoinTable }
148: *
149: */
150: public JoinTable getJoinTable() {
151: return joinTable;
152: }
153:
154: /**
155: * Sets the value of the joinTable property.
156: *
157: * @param value
158: * allowed object is
159: * {@link JoinTable }
160: *
161: */
162: public void setJoinTable(JoinTable value) {
163: this .joinTable = value;
164: }
165:
166: /**
167: * Gets the value of the joinColumn property.
168: *
169: * <p>
170: * This accessor method returns a reference to the live list,
171: * not a snapshot. Therefore any modification you make to the
172: * returned list will be present inside the JAXB object.
173: * This is why there is not a <CODE>set</CODE> method for the joinColumn property.
174: *
175: * <p>
176: * For example, to add a new item, do as follows:
177: * <pre>
178: * getJoinColumn().add(newItem);
179: * </pre>
180: *
181: *
182: * <p>
183: * Objects of the following type(s) are allowed in the list
184: * {@link JoinColumn }
185: *
186: *
187: */
188: public List<JoinColumn> getJoinColumn() {
189: if (joinColumn == null) {
190: joinColumn = new ArrayList<JoinColumn>();
191: }
192: return this .joinColumn;
193: }
194:
195: /**
196: * Gets the value of the cascade property.
197: *
198: * @return
199: * possible object is
200: * {@link CascadeType }
201: *
202: */
203: public CascadeType getCascade() {
204: return cascade;
205: }
206:
207: /**
208: * Sets the value of the cascade property.
209: *
210: * @param value
211: * allowed object is
212: * {@link CascadeType }
213: *
214: */
215: public void setCascade(CascadeType value) {
216: this .cascade = value;
217: }
218:
219: /**
220: * Gets the value of the fetch property.
221: *
222: * @return
223: * possible object is
224: * {@link FetchType }
225: *
226: */
227: public FetchType getFetch() {
228: return fetch;
229: }
230:
231: /**
232: * Sets the value of the fetch property.
233: *
234: * @param value
235: * allowed object is
236: * {@link FetchType }
237: *
238: */
239: public void setFetch(FetchType value) {
240: this .fetch = value;
241: }
242:
243: /**
244: * Gets the value of the mappedBy property.
245: *
246: * @return
247: * possible object is
248: * {@link String }
249: *
250: */
251: public String getMappedBy() {
252: return mappedBy;
253: }
254:
255: /**
256: * Sets the value of the mappedBy property.
257: *
258: * @param value
259: * allowed object is
260: * {@link String }
261: *
262: */
263: public void setMappedBy(String value) {
264: this .mappedBy = value;
265: }
266:
267: /**
268: * Gets the value of the name property.
269: *
270: * @return
271: * possible object is
272: * {@link String }
273: *
274: */
275: public String getName() {
276: return name;
277: }
278:
279: /**
280: * Sets the value of the name property.
281: *
282: * @param value
283: * allowed object is
284: * {@link String }
285: *
286: */
287: public void setName(String value) {
288: this .name = value;
289: }
290:
291: /**
292: * Gets the value of the targetEntity property.
293: *
294: * @return
295: * possible object is
296: * {@link String }
297: *
298: */
299: public String getTargetEntity() {
300: return targetEntity;
301: }
302:
303: /**
304: * Sets the value of the targetEntity property.
305: *
306: * @param value
307: * allowed object is
308: * {@link String }
309: *
310: */
311: public void setTargetEntity(String value) {
312: this .targetEntity = value;
313: }
314:
315: /**
316: * This is only used for xml converters and will normally return null.
317: * Gets the field on the target entity for this relationship.
318: * @return the field on the target entity for this relationship.
319: */
320: public RelationField getRelatedField() {
321: return relatedField;
322: }
323:
324: /**
325: * Gets the field on the target entity for this relationship.
326: * @param value field on the target entity for this relationship.
327: */
328: public void setRelatedField(RelationField value) {
329: this .relatedField = value;
330: }
331:
332: /**
333: * This is only used for xml converters and will normally return false.
334: * A true value indicates that this field was generated for CMR back references.
335: * @return true if this field was generated for CMR back references.
336: */
337: public boolean isSyntheticField() {
338: return syntheticField;
339: }
340:
341: /**
342: * This is only used for xml converters and will normally return false.
343: * A true value indicates that this field was generated for CMR back references.
344: * @return true if this field was generated for CMR back references.
345: */
346: public void setSyntheticField(boolean syntheticField) {
347: this.syntheticField = syntheticField;
348: }
349: }
|