Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
33 | PointedEar | 1 | //$Id: PrimaryKeyJoinColumn.java 11282 2007-03-14 22:05:59Z epbernard $ |
2 | //EJB3 Specification Copyright 2004-2006 Sun Microsystems, Inc. |
||
3 | package javax.persistence; |
||
4 | |||
5 | import java.lang.annotation.Retention; |
||
6 | import java.lang.annotation.Target; |
||
7 | |||
8 | import static java.lang.annotation.ElementType.*; |
||
9 | import static java.lang.annotation.RetentionPolicy.*; |
||
10 | |||
11 | /** |
||
12 | * This annotation specifies a primary key column that is used as a foreign key to join to another |
||
13 | * table. |
||
14 | * |
||
15 | * It is used to join the primary table of an entity subclass in the JOINED mapping strategy to |
||
16 | * the primary table of its superclass; it is used within a SecondaryTable annotation to join a |
||
17 | * secondary table to a primary table; and it may be used in a OneToOne mapping in which the |
||
18 | * primary key of the referencing entity is used as a foreign key to the referenced entity. |
||
19 | * |
||
20 | * If no PrimaryKeyJoinColumn annotation is specified for a subclass in the JOINED mapping |
||
21 | * strategy, the foreign key columns are assumed to have the same names as the primary key |
||
22 | * columns of the primary table of the superclass |
||
23 | * |
||
24 | * @author Emmanuel Bernard |
||
25 | */ |
||
26 | @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) |
||
27 | public @interface PrimaryKeyJoinColumn { |
||
28 | /** |
||
29 | * The name of the primary key column of the current table. |
||
30 | * |
||
31 | * Defaults to the same name as the primary key column of the primary table of the |
||
32 | * superclass (JOINED mapping strategy); the same name as the primary key column of |
||
33 | * the primary table (SecondaryTable mapping); or the same name as the primary key |
||
34 | * column for the table for the referencing entity (OneToOne mapping) |
||
35 | */ |
||
36 | String name() default ""; |
||
37 | /** |
||
38 | * The name of the primary key column of the table being joined to. |
||
39 | * |
||
40 | * Defaults to the same name as the primary key column of the primary table of the |
||
41 | * superclass (JOINED mapping strategy); the same name as the primary key column of the |
||
42 | * primary table (SecondaryTable mapping); or the same name as the primary key column for |
||
43 | * the table for the referencing entity (OneToOne mapping) |
||
44 | */ |
||
45 | String referencedColumnName() default ""; |
||
46 | /** |
||
47 | * The SQL fragment that is used when generating the DDL for the column. This should not be |
||
48 | * specified for a OneToOne primary key association. |
||
49 | * |
||
50 | * Defaults to the generated SQL to create a column of the inferred type. |
||
51 | */ |
||
52 | String columnDefinition() default ""; |
||
53 | } |