KickJava   Java API By Example, From Geeks To Geeks.

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


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
21 package org.apache.cayenne.jpa.map;
22
23 import java.util.ArrayList JavaDoc;
24 import java.util.Collection JavaDoc;
25
26 import javax.persistence.JoinTable;
27
28 import org.apache.cayenne.util.TreeNodeChild;
29
30 public class JpaJoinTable {
31
32     protected String JavaDoc name;
33     protected String JavaDoc catalog;
34     protected String JavaDoc schema;
35
36     protected Collection JavaDoc<JpaJoinColumn> joinColumns;
37     protected Collection JavaDoc<JpaJoinColumn> inverseJoinColumns;
38     protected Collection JavaDoc<JpaUniqueConstraint> uniqueConstraints;
39
40     public JpaJoinTable() {
41
42     }
43
44     public JpaJoinTable(JoinTable annotation) {
45         name = annotation.name();
46         catalog = annotation.catalog();
47         schema = annotation.schema();
48
49         getJoinColumns();
50         for (int i = 0; i < annotation.joinColumns().length; i++) {
51             joinColumns.add(new JpaJoinColumn(annotation.joinColumns()[i]));
52         }
53
54         getInverseJoinColumns();
55         for (int i = 0; i < annotation.inverseJoinColumns().length; i++) {
56             inverseJoinColumns.add(new JpaJoinColumn(annotation.inverseJoinColumns()[i]));
57         }
58
59         getUniqueConstraints();
60         for (int i = 0; i < annotation.uniqueConstraints().length; i++) {
61             uniqueConstraints.add(new JpaUniqueConstraint(
62                     annotation.uniqueConstraints()[i]));
63         }
64     }
65
66     public String JavaDoc getCatalog() {
67         return catalog;
68     }
69
70     public void setCatalog(String JavaDoc catalog) {
71         this.catalog = catalog;
72     }
73
74     public String JavaDoc getName() {
75         return name;
76     }
77
78     public void setName(String JavaDoc name) {
79         this.name = name;
80     }
81
82     public String JavaDoc getSchema() {
83         return schema;
84     }
85
86     public void setSchema(String JavaDoc schema) {
87         this.schema = schema;
88     }
89
90     @TreeNodeChild(type = JpaJoinColumn.class)
91     public Collection JavaDoc<JpaJoinColumn> getInverseJoinColumns() {
92         if (inverseJoinColumns == null) {
93             inverseJoinColumns = new ArrayList JavaDoc<JpaJoinColumn>();
94         }
95
96         return inverseJoinColumns;
97     }
98
99     @TreeNodeChild(type = JpaJoinColumn.class)
100     public Collection JavaDoc<JpaJoinColumn> getJoinColumns() {
101         if (joinColumns == null) {
102             joinColumns = new ArrayList JavaDoc<JpaJoinColumn>();
103         }
104
105         return joinColumns;
106     }
107
108     @TreeNodeChild(type = JpaUniqueConstraint.class)
109     public Collection JavaDoc<JpaUniqueConstraint> getUniqueConstraints() {
110         if (uniqueConstraints == null) {
111             uniqueConstraints = new ArrayList JavaDoc<JpaUniqueConstraint>();
112         }
113
114         return uniqueConstraints;
115     }
116 }
117
Popular Tags