8.12.51 @PrimaryKeyJoinColumn
- Organization of this subsection
(1) Description
This annotation specifies the column used as the external key when binding with another table. This annotation is used in the following cases:
-
When the names of the primary key of the superclass and the primary key of the subclass of an entity are different in the JOINED strategy of the inheritance mapping strategy
-
When the primary table and secondary table are to be bound in @SecondaryTable#
-
When the primary key of the non-owner entity class is used as an external key in the OneToOne relationship
- #
-
Here, this annotation is used within @SecondaryTable.
The applicable targets are class, method, and field.
(2) Element
The following table lists the elements of @PrimaryKeyJoinColumn:
Element name |
Optional/Required |
Element description |
---|---|---|
Optional |
This element specifies the column name for binding the target tables. |
|
Optional |
This element specifies the column name of the primary key of binding-destination table that is referenced by the column specified in the name element. |
|
columnDefinition |
Optional |
This element is used to describe the constraints added to the column in the DDL, when the CREATE statement is output. 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 column name for binding the target tables.
The column name that can be specified depends on the database specifications.
- Default value
-
-
When the JOINED strategy is used
Column name of the primary key of primary table of the superclass
-
When @SecondaryTable is used
Column name of the primary key of primary table
-
When the OneToOne relationship is used
Column name of the primary key of target entity table
-
(b) referencedColumnName element
- Type
-
String
- Description
-
This element specifies the column name of the primary key of binding-destination table that is referenced by the column specified in the name element. Specify the same value as the character string of the name element of @Column. Arrange the upper case and lower case characters in the character string to be specified.
The column name that can be specified depends on the database specifications.
Even when the unique key constraints are used instead of specifying the primary key in the column in the OneToOne relationship, the operation will continue, but will not be guaranteed.
- Default value
-
-
When the JOINED strategy is used
Column name of the primary key of primary table of the superclass
-
When @SecondaryTable is used
Column name of the primary key of primary table
-
When the OneToOne relationship is used
Column name of the primary key of target entity table
-