I'm working with Doctrine2.2.2 in conjunction with Symfony 2.0.15. I notice that when using Class Table Inheritance, for example:
/**
* @Entity
* @InheritanceType("JOINED")
* @DiscriminatorColumn(name="discr", type="string")
* @DiscriminatorMap({"person" = "Person", "employee" = "Employee"})
*/
this will create a foreign key cascading delete constraint on child entities/tables (in this case Employee). Doctrine's documentation on this contains an important-looking yellow box that reads:
When you do not use the SchemaTool to generate the required SQL you should know that deleting a class table inheritance makes use of the foreign key property ON DELETE CASCADE in all database implementations. A failure to implement this yourself will lead to dead rows in the database.
Which doesn't make sense to me. Does this mean that if you don't use the SchemaTool then Doctrine will create the foreign key cascading delete constraint? If one did use the SchemaTool, would Doctrine use it's built-in cascade capabilities instead?
What is is saying is that when you generate the SQL with the SchemaTool, it will also add the appropriate ON DELETE CASCADE part to your foreign key constraint.
If you don't use the SchemaTool, you need to make sure that the foreign key constraint has the ON DELETE CASCADE part, or when you delete rows from the Employee table you will end up with orphaned rows in your parent table.