Skip to content


DDC-1921: Clarify Identifier definition for CTI entities #2590

doctrinebot opened this Issue · 0 comments

2 participants


Jira issue originally created by user i3ncls:


Reference Guide topic 4.8 Identifers/Primary Keys( states that: "Every entity class needs an identifier/primary key."

However, example in topic 7.3. Class Table Inheritance ( doesn't contain any definitions for Ids.

Consider following code:

 * @Entity
 * @InheritanceType("JOINED")
 * @DiscriminatorColumn(name="discr", type="string")
 * @DiscriminatorMap({"person" = "Person", "employee" = "Employee"})
class Person
    /*** @Id @Column(type="integer") **/
    private $id;

    public function getId() {
        return $this->id;

/*** @Entity **/
class Employee extends Person
    /*** @Id @Column(type="integer") **/
    private $id;

    // Overrides parent to retrieve private
    public function getId() {
        return $this->id;

// create instances and $em->persist(...)

// $person instanceof Person
$person->getId(); // Returns id.

// $employee instanceof Employee
$employee->getId(); // Returns null. Private $id in subclass isn't assigned.

Please clarify correct use of identifiers in CTI subclass entities. Should subclasses contain any definitions of identifiers?

Thank you!


@beberlei beberlei was assigned by doctrinebot
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.