Annotation Interface JoinTable


@Target({METHOD,FIELD}) @Retention(RUNTIME) public @interface JoinTable
Customizes the join table of a ONE_TO_MANY or MANY_TO_MANY association that is stored in a separate table. A join table (also called a link table) has one row per linked pair of entities, holding a foreign key to the owning entity and a foreign key to the associated entity.

Without this annotation, the table name and the column names are derived from the entity and association names by the NamingStrategy. Use name() and schema() to name the table, joinColumns() to name the columns that reference the owning entity and inverseJoinColumns() to name the columns that reference the associated entity. Place the annotation on the owning side of the association, that is the side without mappedBy.

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

Since:
1.0.0
Author:
graemerocher
  • Element Details

    • name

      String name
      Returns:
      The name of the join table
      Default:
      ""
    • joinColumns

      JoinColumn[] joinColumns
      Returns:
      The join columns to use.
      Default:
      {}
    • inverseJoinColumns

      JoinColumn[] inverseJoinColumns
      Returns:
      The inverse join columns to use.
      Default:
      {}
    • alias

      String alias
      Returns:
      The alias to use for the query
      Default:
      ""
    • schema

      String schema
      Returns:
      The schema of the join table
      Default:
      ""