I am trying to update my database schema but I am getting following error:
[Doctrine\ORM\Mapping\MappingException]
It is illegal to put an inverse side one-to-many or many-to-many association on mapped superclass 'AppBundle\Entity\ListContent#attachments'.
I have following entity hierarchy:
Content
entity is concrete class for Single table inheritance where I store all of my content eg. Page
, Blog
, etc.
In Content
entity I have one-to-many
relation to Attachment
entity like this:
/**
* @var ArrayCollection|Attachment
*
* @ORM\OneToMany(targetEntity="AppBundle\Entity\Attachment", mappedBy="content")
*/
protected $attachments;
and of course on Attachment
entity I have:
/**
* @var Content
*
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Content", inversedBy="attachments")
*/
private $content;
Some of STI entities extends Content
entity but some of them extends abstract ListContent
which is defined as mapped superclass
and has some additional fields.
I want to be able to access attachments
either from entities which extends Content
and also entities which extends ListContent
so I've put one-to-may
association to Content
entity since ListContent
is extending it.
i was looking for solution but I can only find this one Doctrine2: OneToMany on mapped superclass and it is not appropriate for me since I don't want to define relationship on my ListContent
.
Does anyone came across this issue? How did you resolve it?