KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > jpa > map > JpaOneToMany


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20 package org.apache.cayenne.jpa.map;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.Collection JavaDoc;
24
25 import javax.persistence.OneToMany;
26
27 import org.apache.cayenne.util.TreeNodeChild;
28
29 public class JpaOneToMany extends JpaRelationship {
30
31     protected String JavaDoc mappedBy;
32     protected Collection JavaDoc<JpaJoinColumn> joinColumns;
33     protected JpaJoinTable joinTable;
34     protected String JavaDoc orderBy;
35     protected String JavaDoc mapKey;
36
37     public JpaOneToMany() {
38
39     }
40
41     public JpaOneToMany(OneToMany annotation) {
42         if (!Void.TYPE.equals(annotation.targetEntity())) {
43             this.targetEntityName = annotation.targetEntity().getName();
44         }
45
46         for (int i = 0; i < annotation.cascade().length; i++) {
47             if (cascade == null) {
48                 cascade = new JpaCascade();
49             }
50             cascade.getCascades().add(annotation.cascade()[i]);
51         }
52
53         fetch = annotation.fetch();
54         mappedBy = annotation.mappedBy();
55     }
56
57     @Override JavaDoc
58     public boolean isToMany() {
59         return true;
60     }
61
62     @TreeNodeChild(type = JpaJoinColumn.class)
63     public Collection JavaDoc<JpaJoinColumn> getJoinColumns() {
64         if (joinColumns == null) {
65             joinColumns = new ArrayList JavaDoc<JpaJoinColumn>();
66         }
67         return joinColumns;
68     }
69
70     public JpaJoinTable getJoinTable() {
71         return joinTable;
72     }
73
74     public void setJoinTable(JpaJoinTable joinTable) {
75         this.joinTable = joinTable;
76     }
77
78     public String JavaDoc getOrderBy() {
79         return orderBy;
80     }
81
82     public void setOrderBy(String JavaDoc orderBy) {
83         this.orderBy = orderBy;
84     }
85
86     public String JavaDoc getMappedBy() {
87         return mappedBy;
88     }
89
90     public void setMappedBy(String JavaDoc mappedBy) {
91         this.mappedBy = mappedBy;
92     }
93
94     
95     public String JavaDoc getMapKey() {
96         return mapKey;
97     }
98
99     
100     public void setMapKey(String JavaDoc mapKey) {
101         this.mapKey = mapKey;
102     }
103 }
104
Popular Tags