DDC-265: Possibility for Nested Inheritance #326

Open
opened 2026-01-22 12:34:56 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 21, 2010).

Jira issue originally created by user quest:

It would be great if Doctrine had the possibility to define a further inharitance in a subclass.

Example:
There is a class DataObject managing things like created- and lastedit-
timestamps, archiving objects before updates, ...
One of the sub-objects is Content.
There are several types of content.
Written directly to a database field, read from a textfile on server,
executed php file on server, loaded from another server via xmlrpc and
so on.

I'd like to use a single table inheritance to map all information of
the different content objects in one table.
If I understand the model right the only alternate solution would be
to write each single content object to the discriminator map of
DataObject.

Originally created by @doctrinebot on GitHub (Jan 21, 2010). Jira issue originally created by user quest: It would be great if Doctrine had the possibility to define a further inharitance in a subclass. Example: There is a class DataObject managing things like created- and lastedit- timestamps, archiving objects before updates, ... One of the sub-objects is Content. There are several types of content. Written directly to a database field, read from a textfile on server, executed php file on server, loaded from another server via xmlrpc and so on. I'd like to use a single table inheritance to map all information of the different content objects in one table. If I understand the model right the only alternate solution would be to write each single content object to the discriminator map of DataObject.
admin added the New Feature label 2026-01-22 12:34:56 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 21, 2010):

@doctrinebot commented on GitHub (Jan 21, 2010): - duplicates [DDC-138: Allow for mixed inheritance mapping](http://www.doctrine-project.org/jira/browse/DDC-138)
Author
Owner

@doctrinebot commented on GitHub (Jan 21, 2010):

Comment created by @beberlei:

The DataObject you describe is a no-go for Doctrine 2. Its just a very bad practice.

Inheritance Mapping is for REAL inheritance only, otherwise you shouldnt go with a relational database in the first place.

You should use the Event system for such changes, it offers you roughly the same possibilities and keeps you from having to use inheritance mapping. You could still create an abstract data object and define the fields that will be used in each "implementation" and then in events do something like:

if ($entity instanceof DataObject) {
     $entity->updated();
     $archiver->makeSnapshot($entity);
}
@doctrinebot commented on GitHub (Jan 21, 2010): Comment created by @beberlei: The DataObject you describe is a no-go for Doctrine 2. Its just a very bad practice. Inheritance Mapping is for REAL inheritance only, otherwise you shouldnt go with a relational database in the first place. You should use the Event system for such changes, it offers you roughly the same possibilities and keeps you from having to use inheritance mapping. You could still create an abstract data object and define the fields that will be used in each "implementation" and then in events do something like: ``` if ($entity instanceof DataObject) { $entity->updated(); $archiver->makeSnapshot($entity); } ```
Author
Owner

@doctrinebot commented on GitHub (Mar 20, 2010):

Comment created by @jwage:

With this patch I think you could setup a nice similar model where you can introduce new children of this parent class and have it added to the discriminator map from the child instead of having to modify the parents mapping information.

http://www.doctrine-project.org/jira/browse/DDC-447

@doctrinebot commented on GitHub (Mar 20, 2010): Comment created by @jwage: With this patch I think you could setup a nice similar model where you can introduce new children of this parent class and have it added to the discriminator map from the child instead of having to modify the parents mapping information. http://www.doctrine-project.org/jira/browse/[DDC-447](http://www.doctrine-project.org/jira/browse/DDC-447)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#326