-
@Target({METHOD,FIELD}) @Retention(RUNTIME) public @interface EmbeddedIdSpecifies that the annotated persistent field or property of an entity class or mapped superclass is the composite primary key of the entity. The type of the annotated field or property must be an embeddable type, and must be explicitly annotatedEmbeddable.If a field or property of an entity class is annotated
EmbeddedId, then no other field or property of the entity may be annotatedIdorEmbeddedId, and the entity class must not declare anIdClass.The embedded primary key type must implement
Annotation.equals(java.lang.Object)andAnnotation.hashCode(), defining value equality consistently with equality of the mapped primary key of the database table.The
AttributeOverrideannotation may be used to override the column mappings declared within the embeddable class.The
MapsIdannotation may be used in conjunction with theEmbeddedIdannotation to declare a derived primary key.If the entity has a derived primary key, the
AttributeOverrideannotation may only be used to override those attributes of the embedded id that do not correspond to the relationship to the parent entity.Relationship mappings defined within an embedded primary key type are not supported.
Example 1: {@snippet :
- Since:
- 1.0
- See Also:
Embeddable,MapsId,IdClass