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

Open
opened 2026-01-22 13:18:15 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Jul 1, 2011).

Originally assigned to: @beberlei on GitHub.

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.

Originally created by @doctrinebot on GitHub (Jul 1, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user asannes: When using inheritance with identifier in the superclass, results in an error trying to generate code. Example: ``` none /**** * 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.
admin added the Bug label 2026-01-22 13:18:15 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1564