Annotation Type ForeignKey
-
@Target({}) @Retention(RUNTIME) public @interface ForeignKeyUsed to specify the handling of foreign key constraints when schema generation is in effect. If this annotation is not specified, the persistence provider's default foreign key strategy will be used.The
ConstraintModevalue is used to specify whether foreign key constraints should be generated.The syntax used in the
foreignKeyDefinitionelement should follow the SQL syntax used by the target database for foreign key constraints. For example, this may be similar the following:FOREIGN KEY ( <COLUMN expression> {, <COLUMN expression>}... ) REFERENCES <TABLE identifier> [ (<COLUMN expression> {, <COLUMN expression>}... ) ] [ ON UPDATE <referential action> ] [ ON DELETE <referential action> ]When theConstraintModevalue isCONSTRAINT, but theforeignKeyDefinitionelement is not specified, the provider will generate foreign key constraints whose update and delete actions it determines most appropriate for the join column(s) to which the foreign key annotation is applied.- See Also:
JoinColumn,JoinColumns,MapKeyJoinColumn,MapKeyJoinColumns,PrimaryKeyJoinColumn,JoinTable,CollectionTable,SecondaryTable,AssociationOverride- Since:
- 2.1
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.StringforeignKeyDefinition(Optional) The foreign key constraint definition.java.lang.Stringname(Optional) The name of the foreign key constraint.ConstraintModevalue(Optional) Used to specify whether a foreign key constraint should be generated when schema generation is in effect.
-
-
-
-
value
ConstraintMode value
(Optional) Used to specify whether a foreign key constraint should be generated when schema generation is in effect.A value of
CONSTRAINTwill cause the persistence provider to generate a foreign key constraint. If theforeignKeyDefinitionelement is not specified, the provider will generate a constraint whose update and delete actions it determines most appropriate for the join column(s) to which the foreign key annotation is applied.A value of
NO_CONSTRAINTwill result in no constraint being generated.A value of
PROVIDER_DEFAULTwill result in the provider's default behavior (which may or may not result in the generation of a constraint for the given join column(s).- Default:
- javax.persistence.ConstraintMode.CONSTRAINT
-
-