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
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionUsed to define the mapping.The name of the foreign column.The name of the column referenced by this foreign column.
-
Element Details
-
name
-
referencedColumnName
String referencedColumnNameThe name of the column referenced by this foreign column.- Returns:
- The referenced column name
- Default:
""
-
columnDefinition
String columnDefinitionUsed 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:
""
-