KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > api > persistence > model > mapping > MappingReferenceKeyElement


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * MappingReferenceKeyElement.java
26  *
27  * Created on March 3, 2000, 1:11 PM
28  */

29
30 package com.sun.jdo.api.persistence.model.mapping;
31
32 import java.util.ArrayList JavaDoc;
33
34 import org.netbeans.modules.dbschema.*;
35
36 import com.sun.jdo.api.persistence.model.ModelException;
37
38 /**
39  * This is an element which represents a relationship between two tables
40  * (primary and secondary). It should not be used for relationship fields
41  * (MappingRelationshipElement has its own set of pairs). It can be thought
42  * of as a "fake foreign key" meaning it designates the column pairs used to
43  * join the primary table with a secondary table. It is analagous to a
44  * foreign key and may in fact contain identical pairs as the foreign key,
45  * but this is not a requirement. The foreign key may define a different
46  * set of pairs or may not exist at all. Although any set of pairs is legal,
47  * the user should be careful to define pairs which represent a logical
48  * relationship between the two tables. The relationship should be set up as
49  * follows:
50  * First, set a primary table for the mapping class. Doing this sets up a
51  * "fake primary key" for the associated mapping table element. Next, add
52  * a secondary table and set up the pairs which establish the connection
53  * on the returned reference key object. This sets up whatever "fake primary
54  * key" information is necessary on the secondary table's mapping table,
55  * establishes the primary to secondary relationship via the reference keys,
56  * and puts the pair information into the "fake foreign key".
57  *
58  * @author Mark Munro
59  * @author Rochelle Raccah
60  * @version %I%
61  */

62 public interface MappingReferenceKeyElement
63     extends MappingMemberElement, ReferenceKey
64 {
65     //======================= table handling ===========================
66

67     /** Returns the mapping table element for this referencing key.
68      * @return the meta data table for this referencing key
69      */

70     public MappingTableElement getTable ();
71
72     /** Set the mapping table for this referencing key to the supplied table.
73      * @param table mapping table element to be used with this key.
74      * @exception ModelException if impossible
75      */

76     public void setTable (MappingTableElement table) throws ModelException;
77
78     //======================= column handling ===========================
79

80     /** Returns the list of relative column pair names in this referencing key.
81      * @return the names of the column pairs in this referencing key
82      */

83     public ArrayList JavaDoc getColumnPairNames ();
84
85     /** Remove a column pair from the holder. This method can be used to
86      * remove a pair by name when it cannot be resolved to an actual pair.
87      * @param pairName the relative name of the column pair to remove
88      * @throws ModelException if impossible
89      */

90     public void removeColumnPair (String JavaDoc pairName) throws ModelException;
91
92     /** Remove some column pairs from the holder. This method can be used to
93      * remove pairs by name when they cannot be resolved to actual pairs.
94      * @param pairNames the relative names of the column pairs to remove
95      * @throws ModelException if impossible
96      */

97     public void removeColumnPairs (ArrayList JavaDoc pairNames) throws ModelException;
98
99     //==== redefined from ReferenceKey to narrow Exception->ModelException ===
100

101     /** Add a new column pair to the holder.
102      * @param pair the pair to add
103      * @throws ModelException if impossible
104      */

105     public void addColumnPair (ColumnPairElement pair) throws ModelException;
106
107     /** Add some new column pairs to the holder.
108      * @param pairs the column pairs to add
109      * @throws ModelException if impossible
110      */

111     public void addColumnPairs (ColumnPairElement[] pairs)
112         throws ModelException;
113
114     /** Remove a column pair from the holder.
115      * @param pair the column pair to remove
116      * @throws ModelException if impossible
117      */

118     public void removeColumnPair (ColumnPairElement pair)
119         throws ModelException;
120
121     /** Remove some column pairs from the holder.
122      * @param pairs the column pairs to remove
123      * @throws ModelException if impossible
124      */

125     public void removeColumnPairs (ColumnPairElement[] pairs)
126         throws ModelException;
127
128     /** Set the column pairs for this holder.
129      * Previous column pairs are removed.
130      * @param pairs the new column pairs
131      * @throws ModelException if impossible
132      */

133     public void setColumnPairs (ColumnPairElement[] pairs)
134         throws ModelException;
135 }
136
Popular Tags