Annotation Interface JoinColumn


@Target({METHOD,FIELD}) @Retention(RUNTIME) @Repeatable(JoinColumns.class) public @interface JoinColumn
Customizes a foreign key column of an association: the column that stores the ID of the associated entity for a MANY_TO_ONE or ONE_TO_ONE association, or one of the columns of a JoinTable.

name() is the name of the foreign key column and referencedColumnName() the column of the referenced table it points to (the primary key by default). The annotation is repeatable, so a foreign key to an entity with a composite ID can declare one column per ID component.

The JPA annotation jakarta.persistence.JoinColumn can be used instead and is interpreted the same way.

Since:
2.4.0
Author:
Denis Stepanov
  • Element Details

    • name

      String name
      The name of the foreign column.
      Returns:
      The name of the foreign column
      Default:
      ""
    • referencedColumnName

      String referencedColumnName
      The name of the column referenced by this foreign column.
      Returns:
      The referenced column name
      Default:
      ""
    • columnDefinition

      String columnDefinition
      Used to define the mapping. For example in the case of SQL this would be the column definition. Example: BLOB NOT NULL.
      Returns:
      A string-based definition of the property type.
      Default:
      ""