[DDC-1921] Clarify Identifier definition for CTI entities Created: 11/Jul/12  Updated: 11/Jul/12

Status: Open
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Documentation Priority: Minor
Reporter: Ludek Stepan Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None



Reference Guide topic 4.8 Identifers/Primary Keys(http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#identifiers-primary-keys) states that: "Every entity class needs an identifier/primary key."

However, example in topic 7.3. Class Table Inheritance (http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/reference/inheritance-mapping.html#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!


Generated at Mon Nov 30 13:51:21 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.