DDC-1205: generate-entities does not work with inheritance and annotations #1514

Closed
opened 2026-01-22 13:16:38 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Jun 13, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user arnaud-lb:

When using inheritance, the generate-entities command fails with messages like No identifier/primary key specified for Entity X. This is because getParentClasses() in DisconnectedClassMetadataFactory always returns an empty array, and the ClassMetadataFactory fails to load parent classes metadata.

Example of mapping that fails with No identifier/primary key specified for Entity Employee:

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

/****
 * @Entity
 */
class Employee extends Person
{
    // ...
}
Originally created by @doctrinebot on GitHub (Jun 13, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user arnaud-lb: When using inheritance, the generate-entities command fails with messages like _No identifier/primary key specified for Entity X_. This is because getParentClasses() in DisconnectedClassMetadataFactory always returns an empty array, and the ClassMetadataFactory fails to load parent classes metadata. Example of mapping that fails with _No identifier/primary key specified for Entity Employee_: ``` /**** * @Entity * @InheritanceType("SINGLE_TABLE") * @DiscriminatorColumn(name="discr", type="string") * @DiscriminatorMap({"person" = "Person", "employee" = "Employee"}) */ class Person { /*** @Id **/ $id; } /**** * @Entity */ class Employee extends Person { // ... } ```
admin added the Bug label 2026-01-22 13:16:38 +01:00
admin closed this issue 2026-01-22 13:16:38 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jun 13, 2011):

Comment created by @beberlei:

yes, inheritance doesnt work with entity generation. Its mentioned in the help of the command and somewhere in the docs.

@doctrinebot commented on GitHub (Jun 13, 2011): Comment created by @beberlei: yes, inheritance doesnt work with entity generation. Its mentioned in the help of the command and somewhere in the docs.
Author
Owner

@doctrinebot commented on GitHub (Jun 13, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jun 13, 2011): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Jun 13, 2011):

Comment created by arnaud-lb:

Sorry, didn't seen this. The problem is that when using only one inherited class, this avoids from using generate-entities at all on any other entity.

By looking at DisconnectedClassMetadataFactory it looks like it could try harder to load metadata if the class exists:

 protected function getParentClasses($name)
 {
<ins>        if (class_exists($name)) {
</ins>            return parent::getParentClasses($name);
+        }
           return array()
 }

With this I managed to genarate my new entities. But is also generates some warnings, so I guess the problem is deeper than that.

Thanks for your answer.

@doctrinebot commented on GitHub (Jun 13, 2011): Comment created by arnaud-lb: Sorry, didn't seen this. The problem is that when using only one inherited class, this avoids from using generate-entities at all on any other entity. By looking at DisconnectedClassMetadataFactory it looks like it could try harder to load metadata if the class exists: ``` protected function getParentClasses($name) { <ins> if (class_exists($name)) { </ins> return parent::getParentClasses($name); + } return array() } ``` With this I managed to genarate my new entities. But is also generates some warnings, so I guess the problem is deeper than that. Thanks for your answer.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1514