KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > persistence > SecondaryTables


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.TYPE JavaDoc;
28 import static java.lang.annotation.RetentionPolicy.RUNTIME JavaDoc;
29
30 /**
31  * This annotation is used to specify multiple secondary tables
32  * for an entity.
33  *
34  * <pre>
35  * Example 1: Multiple secondary tables assuming primary key columns are named the same in all tables.
36  *
37  * &#064;Entity
38  * &#064;Table(name="EMPLOYEE")
39  * &#064;SecondaryTables({
40  * &#064;SecondaryTable(name="EMP_DETAIL"),
41  * &#064;SecondaryTable(name="EMP_HIST")
42  * })
43  * public class Employee { ... }
44  *
45  * Example 2: Multiple secondary tables with differently named primary key columns.
46  *
47  * &#064;Entity
48  * &#064;Table(name="EMPLOYEE")
49  * &#064;SecondaryTables({
50  * &#064;SecondaryTable(name="EMP_DETAIL",
51  * pkJoinColumns=&#064;PrimaryKeyJoinColumn(name="EMPL_ID")),
52  * &#064;SecondaryTable(name="EMP_HIST",
53  * pkJoinColumns=&#064;PrimaryKeyJoinColumn(name="EMPLOYEE_ID"))
54  * })
55  * public class Employee { ... }
56  * </pre>
57  *
58  * @since Java Persistence 1.0
59  */

60 @Target JavaDoc(TYPE)
61 @Retention JavaDoc(RUNTIME)
62
63 public @interface SecondaryTables {
64
65     /** The secondary tables for an entity. */
66     SecondaryTable[] value();
67 }
68
Popular Tags