Details
Description
Problem is that after merging the object with a reference to some other entity with inheritance (is one of the superclass's discriminator map), the referenced object has wrong instance (it is Proxy object). It is instance of the superclass not the extended class.
In my test case I have joined inheritance model with only two entities to make things simple as possible.
First is the base entity (I have even marked it as abstract):
/** * @Entity * @InheritanceType("JOINED") * @DiscriminatorColumn(name="discr", type="integer") * @DiscriminatorMap({1 = "Entity"}) */ abstract class AbstractEntity
and one entity which extends from the first one:
/** * @Entity */ class Entity extends AbstractEntity { /** * @ManyToOne(targetEntity="AbstractEntity") * @var AbstractEntity */ protected $reference;
In this scheme I've got 2 objects, first referencing to the second. They both are inserted in the database with no problems.
$child = new Entity(); $parent = new Entity(); $child->setReference($parent);
After the flush I try merging the child entity into the entity manager, the parent entity reference is not instance of Entity\Entity anymore.
You can see full test case in the archive attached.
Attached standardized test case.