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

Closed
doctrinebot opened this Issue Jul 1, 2011 · 6 comments

2 participants

@doctrinebot

Jira issue originally created by user asannes:

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.

@doctrinebot

Comment created by venimus:

you should also check if there is a parentclass registered

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

Comment created by asannes:

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

@doctrinebot

Comment created by @beberlei:

Fixed

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.1.1 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment