-
@Target(value={}) @Retention(value=RUNTIME) public @interface ForeignKey
Used 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
ConstraintMode
value is used to specify whether foreign key constraints should be generated.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> ]
When theConstraintMode
value isCONSTRAINT
, but theforeignKeyDefinition
element 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.- Since:
- Java Persistence 2.1
- See Also:
JoinColumn
,JoinColumns
,MapKeyJoinColumn
,MapKeyJoinColumns
,PrimaryKeyJoinColumn
,JoinTable
,CollectionTable
,SecondaryTable
,AssociationOverride
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element and Description String
foreignKeyDefinition
(Optional) The foreign key constraint definition.String
name
(Optional) The name of the foreign key constraint.ConstraintMode
value
(Optional) Used to specify whether a foreign key constraint should be generated when schema generation is in effect.
-
-
-
Element Detail
-
name
public abstract String name
(Optional) The name of the foreign key constraint. If this is not specified, it defaults to a provider-generated name.- Default:
- ""
-
-
-
value
public abstract ConstraintMode value
(Optional) Used to specify whether a foreign key constraint should be generated when schema generation is in effect.A value of
CONSTRAINT
will cause the persistence provider to generate a foreign key constraint. If theforeignKeyDefinition
element 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_CONSTRAINT
will result in no constraint being generated.A value of
PROVIDER_DEFAULT
will 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
-
-
-
foreignKeyDefinition
public abstract String foreignKeyDefinition
(Optional) The foreign key constraint definition.- Default:
- ""
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 18/08/2025 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-javaee-rf-javax/persistence/ForeignKey.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur van deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.