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