Skip to content


DDC-1243: Problem to generate code for subclasses without identifiers. #1852

doctrinebot opened this Issue · 6 comments

2 participants


Jira issue originally created by user asannes:

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


 * 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.


Comment created by venimus:

you should also check if there is a parentclass registered

19: if ( ! $this->driver->isTransient($parentClass) && !empty($this->loadedMetadata[$parentClass])) {

Comment created by asannes:

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


Comment created by @beberlei:



Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.1.1 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.