KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > persistence > JoinTable


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 package javax.persistence;
24
25 import java.lang.annotation.Target JavaDoc;
26 import java.lang.annotation.Retention JavaDoc;
27 import static java.lang.annotation.ElementType.FIELD JavaDoc;
28 import static java.lang.annotation.ElementType.METHOD JavaDoc;
29 import static java.lang.annotation.RetentionPolicy.RUNTIME JavaDoc;
30
31 /**
32  * This annotation is used in the mapping of associations. It
33  * is specified on the owning side of a many-to-many association,
34  * or in a unidirectional one-to-many association.
35  *
36  * <p> If the <code>JoinTable</code> annotation is missing, the
37  * default values of the annotation elements apply. The name
38  * of the join table is assumed to be the table names of the
39  * associated primary tables concatenated together (owning side
40  * first) using an underscore.
41  *
42  * <pre>
43  *
44  * Example:
45  * &#064;JoinTable(
46  * name="CUST_PHONE",
47  * joinColumns=
48  * &#064;JoinColumn(name="CUST_ID", referencedColumnName="ID"),
49  * inverseJoinColumns=
50  * &#064;JoinColumn(name="PHONE_ID", referencedColumnName="ID")
51  * )
52  * </pre>
53  *
54  * @since Java Persistence 1.0
55  */

56 @Target JavaDoc({METHOD, FIELD})
57 @Retention JavaDoc(RUNTIME)
58
59 public @interface JoinTable {
60
61     /**
62      * (Optional) The name of the join table.
63      *
64      * <p> Defaults to the concatenated names of
65      * the two associated primary entity tables,
66      * separated by an underscore.
67      */

68     String JavaDoc name() default "";
69
70     /** (Optional) The catalog of the table.
71      * <p> Defaults to the default catalog.
72      */

73     String JavaDoc catalog() default "";
74
75     /** (Optional) The schema of the table.
76      * <p> Defaults to the default schema for user.
77      */

78     String JavaDoc schema() default "";
79
80     /**
81      * (Optional) The foreign key columns
82      * of the join table which reference the
83      * primary table of the entity owning the
84      * association (i.e. the owning side of
85      * the association).
86      *
87      * <p> Uses the same defaults as for {@link JoinColumn}.
88      */

89     JoinColumn[] joinColumns() default {};
90
91     /**
92      * (Optional) The foreign key columns
93      * of the join table which reference the
94      * primary table of the entity that does
95      * not own the association (i.e. the
96      * inverse side of the association).
97      *
98      * <p> Uses the same defaults as for {@link JoinColumn}.
99      */

100     JoinColumn[] inverseJoinColumns() default {};
101
102     /**
103      * (Optional) Unique constraints that are
104      * to be placed on the table. These are
105      * only used if table generation is in effect.
106      * <p> Defaults to no additional constraints.
107      */

108     UniqueConstraint[] uniqueConstraints() default {};
109 }
110
Popular Tags