Doctrine2: OneToMany on mapped superclass

In others cases happens when you declare @ORM\Entity in an abstract superior class instead of @ORM\MappedSuperclass


A mapped superclass cannot be an entity, it is not query-able and persistent relationships defined by a mapped superclass must be unidirectional (with an owning side only). This means that One-To-Many associations are not possible on a mapped superclass at all. Furthermore Many-To-Many associations are only possible if the mapped superclass is only used in exactly one entity at the moment. For further support of inheritance, the single or joined table inheritance features have to be used.

Check it out here: https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/inheritance-mapping.html


In some cases, when you have such error when inherit from the class that is tagged as @ORM\MappedSuperclass, try to change your properties access level from private to protected