Composite primary key definition via attributes after upgrading to Doctrine ORM 3.0
0 reputation · 03 Mar 2020, 13:57 UTC
When migrating a project to Doctrine ORM 3.0, we aim to define a composite primary key that includes fields from an embeddable class using PHP 8 attributes.
The current documentation states that the #[ORM\Id] attribute must be placed on scalar fields of the owning entity and does not permit identifier mapping inside embeddable classes.
We need to clarify whether this restriction is a hard limitation of the attribute mapping layer or if there exists a configuration or workaround that allows embeddable fields to participate in a composite key.
Is it possible to define a composite primary key that includes #[ORM\Id] on embeddable fields in Doctrine ORM 3.0? If not, what is the recommended approach to model a logical key that spans embeddable properties without violating mapping rules? Are there any planned changes in upcoming Doctrine releases regarding embeddable identifier support?