EclipseLink 2.5.0, build 'v20121016-ab08992' API Reference

javax.persistence
Annotation Type ForeignKey


@Target(value={})
@Retention(value=RUNTIME)
public @interface ForeignKey

Used in schema generation to override the persistence provider's default foreign key strategy. It is used to define a foreign key constraint or to otherwise override or disable the persistence provider's default foreign key definition.

The syntax used in the foreignKeyDefinition element 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> ]
 
If disableForeignKey is true, the persistence provider must not generate a foreign key constraint.

See Also:
JoinColumn, JoinColumns, MapKeyJoinColumn, MapKeyJoinColumns, PrimaryKeyJoinColumn, PrimaryKeyJoinColumns
Since:
Java Persistence 2.1

Optional Element Summary
 boolean disableForeignKey
          (Optional) Used to specify that the persistence provider should not generate a foreign key constraint.
 java.lang.String foreignKeyDefinition
          (Optional) The foreign key constraint definition.
 java.lang.String name
          (Optional) The name of the foreign key constraint.
 

name

public abstract java.lang.String name
(Optional) The name of the foreign key constraint. If this is not specified, it defaults to a provider-generated name.

Default:
""

foreignKeyDefinition

public abstract java.lang.String foreignKeyDefinition
(Optional) The foreign key constraint definition. If this is not specified, and disableForeignKey is false, the persistence provider's default foreign key strategy will apply.

Default:
""

disableForeignKey

public abstract boolean disableForeignKey
(Optional) Used to specify that the persistence provider should not generate a foreign key constraint.

Default:
false

EclipseLink 2.5.0, build 'v20121016-ab08992' API Reference