Annotation Type ForeignKey


  • @Target({})
    @Retention(RUNTIME)
    public @interface ForeignKey
    The ForeignKey annotation is used in schema generation. It is used to define a foreign key constraint or to override or disable the persistence provider’s default foreign key definition.
    Since:
    JPA 2.1
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String foreignKeyDefinition
      (Optional) The foreign key constraint definition.
      java.lang.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

        java.lang.String name
        (Optional) The name of the foreign key constraint. Defaults to a provider-generated name.
        Returns:
        The foreign key name
        Default:
        ""
      • foreignKeyDefinition

        java.lang.String foreignKeyDefinition
        (Optional) The foreign key constraint definition. Default is provider defined. If the value of disableForeignKey is true, the provider must not generate a foreign key constraint.
        Returns:
        The foreign key definition
        Default:
        ""
      • value

        ConstraintMode value
        (Optional) Used to specify whether a foreign key constraint should be generated when schema generation is in effect.
        Default:
        javax.persistence.ConstraintMode.CONSTRAINT