Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1383

Inheritance superclass object is created after merging entity referencing to discriminated entity

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.1
    • Fix Version/s: 2.1.3, 2.2
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      Ubuntu 11.04, MySQL 5.1.54-1ubuntu4, PHP 5.3.5-1ubuntu7.2

      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.

        Activity

        Hide
        Aigars Gedroics added a comment -

        Attached standardized test case.

        Show
        Aigars Gedroics added a comment - Attached standardized test case.
        Hide
        Benjamin Eberlei added a comment -

        Fixed.

        Show
        Benjamin Eberlei added a comment - Fixed.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Aigars Gedroics
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: