Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1243

Problem to generate code for subclasses without identifiers.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Git Master
    • Fix Version/s: 2.1.1
    • Component/s: ORM, Tools
    • Security Level: All
    • Labels:
      None

      Description

      When using inheritance with identifier in the superclass, results in an error trying to generate code.

      Example:

      /**
       * Demo\TestInheritanceBundle\Entity\TestBase
       *
       * @ORM\Table()
       * @ORM\Entity
       * @ORM\InheritanceType("JOINED")
       * @ORM\DiscriminatorColumn(name="discr", type="string")
       * @ORM\DiscriminatorMap({"test" = "Test"})
       */
      class TestBase
      {
          /**
           * @var integer $id
           *
           * @ORM\Column(name="id", type="integer")
           * @ORM\Id
           * @ORM\GeneratedValue(strategy="AUTO")
           */
          private $id;
      }
      
      class Test
      {
      }
      
      

      will throw an exception because the DisconnectedClassMetadataFactory disables the code that examines the parent classes.
      I've created a simple function that can be used to figure out if a parent has defined an identifier that can be used by the subclass.

      Patch attached.

        Issue Links

          Activity

          Hide
          venimus added a comment -

          you should also check if there is a parentclass registered

          19: if ( ! $this->driver->isTransient($parentClass) && !empty($this->loadedMetadata[$parentClass])) {
          
          Show
          venimus added a comment - you should also check if there is a parentclass registered 19: if ( ! $this->driver->isTransient($parentClass) && !empty($this->loadedMetadata[$parentClass])) {
          Hide
          Asbjørn Sannes added a comment -

          Updated patch with suggestion from venimus to check if the parent class is loaded before using it.

          Show
          Asbjørn Sannes added a comment - Updated patch with suggestion from venimus to check if the parent class is loaded before using it.
          Hide
          Benjamin Eberlei added a comment -

          Fixed

          Show
          Benjamin Eberlei added a comment - Fixed

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Asbjørn Sannes
            • Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: