8.12.30 @MapKey
- Organization of this subsection
(1) Description
This annotation specifies the map key used for object identification within the map when the non-owner entity class is indicated by the java.util.Map type, in the OneToMany relationship or ManyToMany relationship.
When the name element is not specified, the primary key of the correlated entity is used as the map key.
If mapping is done as @IdClass when the primary key is a compound primary key, the compound primary key is used as the map key.
If a persistence field or persistence property other than the primary key is used as the map key, the unique key constraints related to the map key can be included.
The applicable targets are method and field.
(2) Element
The following table lists the elements of @MapKey:
Element name |
Optional/Required |
Element description |
---|---|---|
Optional |
This element specifies the name of the persistence field or persistence property of the non-owner entity class that is used as the map key. |
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 persistence field or persistence property of the non-owner entity class that is used as the map key.
- Default value
-
Name of the primary key field or property of the non-owner entity class