Subversion Repositories WebE

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
33 PointedEar 1
//$Id: JoinColumn.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
 * Is used to specify a mapped column for joining an entity association.
13
 *
14
 * @author Emmanuel Bernard
15
 */
16
@Target({METHOD, FIELD}) @Retention(RUNTIME)
17
public @interface JoinColumn {
18
        /**
19
         * The name of the foreign key column.
20
         * The table in which it is found depends upon the context. If the join is for a OneToOne
21
         * or Many- ToOne mapping, the foreign key column is in the table of the source entity.
22
         * If the join is for a ManyToMany, the foreign key is in a join table. Default (only applies
23
         * if a single join column is used): The concatenation of the following: the name of the referencing
24
         * relationship property or field of the referencing entity; "_"; the name of the referenced primary
25
         * key column. If there is no such referencing relationship property or field in the entity, the join
26
         * column name is formed as the concatenation of the following: the name of the entity; "_"; the name
27
         * of the referenced primary key column.
28
         */
29
        String name() default "";
30
        /**
31
         * The name of the column referenced by this foreign key column. When used with relationship mappings,
32
         * the referenced column is in the table of the target entity. When used inside a JoinTable annotation,
33
         * the referenced key column is in the entity table of the owning entity, or inverse entity if the join
34
         * is part of the inverse join definition. Default (only applies if single join column is being used):
35
         * The same name as the primary key column of the referenced table.
36
         */
37
        String referencedColumnName() default "";
38
        /**
39
         * Whether the property is a unique key. This is a shortcut for the UniqueConstraint annotation at the
40
         * table level and is useful for when the unique key constraint is only a single field. It is not
41
         * necessary to explicitly specify this for a join column that corresponds to a primary key that is part
42
         * of a foreign key.
43
         */
44
        boolean unique() default false;
45
        /**
46
         * Whether the foreign key column is nullable
47
         */
48
        boolean nullable() default true;
49
        /**
50
         * Whether the column is included in SQL INSERT statements generated by the persistence provider
51
         */
52
        boolean insertable() default true;
53
        /**
54
         * Whether the column is included in SQL UPDATE statements generated by the persistence provider
55
         */
56
        boolean updatable() default true;
57
        /**
58
         * The SQL fragment that is used when generating the DDL for the column.
59
         * Defaults to the generated SQL for the column.
60
         */
61
        String columnDefinition() default "";
62
        /**
63
         * The name of the table that contains the column. If a table is not specified, the column is
64
         * assumed to be in the primary table of the applicable entity
65
         */
66
        String table() default "";
67
}