Details
-
Type:
Documentation
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Documentation
-
Security Level: All
-
Labels:None
Description
Hello,
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!
Ludek