8.12.26 @JoinTable
- Organization of this subsection
(1) Description
This annotation specifies the binding table set up in the following classes:
-
Owner class when the ManyToMany relationship is specified
-
Class containing a single-direction OneToMany relationship
When the name element is not specified, the name of the binding table becomes as follows:
owner-table-name_non-owner-table-name
The applicable targets are method and field.
(2) Element
The following table lists the elements of @JoinTable:
Element name |
Optional/Required |
Element description |
---|---|---|
Optional |
This element specifies the name of the binding table. |
|
catalog |
Optional |
This element specifies the catalog name of the binding table. Note that Cosminexus JPA provider does not support this attribute. |
Optional |
This element specifies the schema name of the binding table. |
|
Optional |
This element specifies the external key column of the binding table that references the primary table of the owner entity. |
|
Optional |
This element specifies the external key column of the binding table that references the primary table of the non-owner entity. |
|
uniqueConstraints |
Optional |
This element specifies the unique constraints of the table. Note that Cosminexus JPA provider does not support this attribute. |
The details of attributes that are supported with Cosminexus JPA provider are as follows:
(a) name element
- Type
-
String
- Description
-
This element specifies the name of the binding table.
The table name that can be specified depends on the database specifications.
- Default value
-
owner-table-name_non-owner-table-name
(b) schema element
- Type
-
String
- Description
-
This element specifies the schema name of the table.
The value that can be specified depends on the specifications of the database schema name.
- Default value
-
Default schema of the database used
(c) joinColumns element
- Type
-
JoinColumn[]
- Description
-
This element specifies the external key column of the binding table that references the primary table of the owner entity. This element specifies an array of @JoinColumn. The external key column name of the binding table is specified in the name element, while the referenced column name of the owner is specified in the referencedColumnName element of @JoinColumn.
The column names that can be specified depend on the database specifications.
- Default value
-
External key of @JoinColumn
(d) inverseJoinColumns element
- Type
-
JoinColumn[]
- Description
-
This element specifies the external key column of the binding table that references the primary table of the non-owner entity. This element specifies an array of @JoinColumn. The external key column name of the binding table is specified in the name element, while the column of the binding-destination table that is referenced by the external key column is specified in the referencedColumnName element of @JoinColumn.
The values that can be specified depend on the specifications of the database column name.
- Default value
-
External key column of @JoinColumn