Jira issue originally created by user gnuffo1:
If I have a class called AbstractPage, with this single table inheritance mapping linking to the folllowing classes (Page, Article, Review), then it works fine:
If however I rename the classes to the Zend framework format, within modules (DefaultModel_AbstractPage, Default_Model_Page, Article_Model_Article, Article_ModelReview), then because Article is before Default, then the schema tool gets confused and throws an error - [Doctrine\DBAL\Schema\SchemaException] The table with name 'pages' already exists. Everything else is the same but the class names.
I have attached examples of this both working and nonworking with the different naming schemes. As you can see everything else is the same.
Comment created by @beberlei:
if yo uspecify class="page" the class has to be called Page, not DefaultModelPage. You have to change the mapping to:
<discriminator-column name="discr" type="string" />
<discriminator-mapping value="page" class="Default*Model*Page" />
<discriminator-mapping value="article" class="Default*Model*Article" />
<discriminator-mapping value="review" class="Default*Model*Review" />
You cannot re-use the mapping for different classes, it has to be bound specifically to an exisiting class.
Comment created by gnuffo1:
I probably wasn't being explicit enough - when I said I rename the classes I also meant that I renamed them in all of the mapping, so I've got this:
And I've also renamed the mapping files themselves from Page.dcm.xml to DefaultModelPage.dcm.xml and so on. Still doesn't work.
I've found a workaround for now. Move the subclasses into another folder (I've create a subfolder called "subclasses") and then add the second line:
$driverImpl = new Doctrine\ORM\Mapping\Driver\XmlDriver(DIR . '/mappings');
$driverImpl->addPaths(array(DIR . '/mappings/subclasses'));
That way the second folder will get read after the parent classes.
This issue was fixed in another ticket.
Issue was closed with resolution "Duplicate"