Skip to content

Loading…

DDC-1383: Inheritance superclass object is created after merging entity referencing to discriminated entity #2003

Closed
doctrinebot opened this Issue · 4 comments

2 participants

@doctrinebot

Jira issue originally created by user gedrox:

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.

@doctrinebot

Comment created by gedrox:

Attached standardized test case.

@doctrinebot

Comment created by @beberlei:

Fixed.

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.1.3 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.