Doctrine Projecthttp://www.doctrine-project.org/jira
This file is an XML representation of an issueen-us6.2.3626015-04-2014[DDC-265] Possibility for Nested Inheritancehttp://www.doctrine-project.org/jira/browse/DDC-265
Doctrine 2 - ORM<p>It would be great if Doctrine had the possibility to define a further inharitance in a subclass.</p>
<p>Example:<br/>
There is a class DataObject managing things like created- and lastedit-<br/>
timestamps, archiving objects before updates, ...<br/>
One of the sub-objects is Content.<br/>
There are several types of content.<br/>
Written directly to a database field, read from a textfile on server,<br/>
executed php file on server, loaded from another server via xmlrpc and<br/>
so on. </p>
<p>I'd like to use a single table inheritance to map all information of<br/>
the different content objects in one table.<br/>
If I understand the model right the only alternate solution would be<br/>
to write each single content object to the discriminator map of<br/>
DataObject. </p>DDC-265Possibility for Nested InheritanceNew FeatureMajorOpenUnresolvedAllRoman S. BorschelMichael FürmannThu, 21 Jan 2010 06:27:37 +0000Wed, 16 Jan 2013 08:16:23 +0000ORM00<p>The DataObject you describe is a no-go for Doctrine 2. Its just a very bad practice.</p>
<p>Inheritance Mapping is for REAL inheritance only, otherwise you shouldnt go with a relational database in the first place.</p>
<p>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:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">if</span> ($entity <span class="code-keyword">instanceof</span> DataObject) {
$entity-&gt;updated();
$archiver-&gt;makeSnapshot($entity);
}
</pre>
</div></div><p>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.</p>
<p><a href="http://www.doctrine-project.org/jira/browse/DDC-447" class="external-link" rel="nofollow">http://www.doctrine-project.org/jira/browse/DDC-447</a></p>DuplicateDDC-138