DDC-599: Inheritance breaks cascading #735

Closed
opened 2026-01-22 12:48:28 +01:00 by admin · 7 comments
Owner

Originally created by @doctrinebot on GitHub (May 18, 2010).

Jira issue originally created by user nicokaiser:

When using inheritance, cascade={"delete"} does not work anymore:

This example creates three Entities:

  • Item
  • SubItem (extends Item)
  • Child

The Item has a OneToMany association with Child with cascade={"delete"}, so if an Item is deleted, its Children are deleted too.

http://pastie.org/965096

However this does not work, the cascade is ignored when the Item is deleted. Without inheritance (e.g. only Item with Children) it works perfectly.

Originally created by @doctrinebot on GitHub (May 18, 2010). Jira issue originally created by user nicokaiser: When using inheritance, cascade={"delete"} does not work anymore: This example creates three Entities: - Item - SubItem (extends Item) - Child The Item has a OneToMany association with Child with cascade={"delete"}, so if an Item is deleted, its Children are deleted too. http://pastie.org/965096 However this does not work, the cascade is ignored when the Item is deleted. Without inheritance (e.g. only Item with Children) it works perfectly.
admin added the Bug label 2026-01-22 12:48:28 +01:00
admin closed this issue 2026-01-22 12:48:30 +01:00
Author
Owner

@doctrinebot commented on GitHub (May 18, 2010):

Comment created by nicokaiser:

By the way, this cannot be reproduced with the included testcases (no DB connection). So the problem may be between the ORM and the DBAL...

@doctrinebot commented on GitHub (May 18, 2010): Comment created by nicokaiser: By the way, this cannot be reproduced with the included testcases (no DB connection). So the problem may be between the ORM and the DBAL...
Author
Owner

@doctrinebot commented on GitHub (May 18, 2010):

Comment created by romanb:

Do you get any error message? exception? stack trace?

@doctrinebot commented on GitHub (May 18, 2010): Comment created by romanb: Do you get any error message? exception? stack trace?
Author
Owner

@doctrinebot commented on GitHub (May 18, 2010):

Comment created by nicokaiser:

PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (kaiser*sandbox.Child, CONSTRAINT Child_ibfk*1 FOREIGN KEY (parentId) REFERENCES Item (id))' in /home/kaiser/doctrine/doctrine/lib/Doctrine/DBAL/Connection.php:637
Stack trace:
#0 /home/kaiser/doctrine/doctrine/lib/Doctrine/DBAL/Connection.php(637): PDOStatement->execute(Array)
#1 /home/kaiser/doctrine/doctrine/lib/Doctrine/DBAL/Connection.php(385): Doctrine\DBAL\Connection->executeUpdate('DELETE FROM Ite...', Array)
#2 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php(353): Doctrine\DBAL\Connection->delete('Item', Array)
#3 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/UnitOfWork.php(777): Doctrine\ORM\Persisters\BasicEntityPersister->delete(Object(Entities\SubItem))
#4 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/UnitOfWork.php(316): Doctrine\ORM\UnitOfWork->_executeDeletions(Object(Doctri in /home/kaiser/doctrine/doctrine/lib/Doctrine/DBAL/Connection.php on line 637

@doctrinebot commented on GitHub (May 18, 2010): Comment created by nicokaiser: PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`kaiser*sandbox`.`Child`, CONSTRAINT `Child_ibfk*1` FOREIGN KEY (`parentId`) REFERENCES `Item` (`id`))' in /home/kaiser/doctrine/doctrine/lib/Doctrine/DBAL/Connection.php:637 Stack trace: #0 /home/kaiser/doctrine/doctrine/lib/Doctrine/DBAL/Connection.php(637): PDOStatement->execute(Array) #1 /home/kaiser/doctrine/doctrine/lib/Doctrine/DBAL/Connection.php(385): Doctrine\DBAL\Connection->executeUpdate('DELETE FROM Ite...', Array) #2 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php(353): Doctrine\DBAL\Connection->delete('Item', Array) #3 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/UnitOfWork.php(777): Doctrine\ORM\Persisters\BasicEntityPersister->delete(Object(Entities\SubItem)) #4 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/UnitOfWork.php(316): Doctrine\ORM\UnitOfWork->_executeDeletions(Object(Doctri in /home/kaiser/doctrine/doctrine/lib/Doctrine/DBAL/Connection.php on line 637
Author
Owner

@doctrinebot commented on GitHub (May 19, 2010):

Comment created by romanb:

Scheduled for beta2 but not sure we can make it, might end up on beta3. Increasing priority though as this seems to be a bug and these have priority.

@doctrinebot commented on GitHub (May 19, 2010): Comment created by romanb: Scheduled for beta2 but not sure we can make it, might end up on beta3. Increasing priority though as this seems to be a bug and these have priority.
Author
Owner

@doctrinebot commented on GitHub (Jun 6, 2010):

Comment created by @beberlei:

Attached a test-case that verifies this bug exists.

Problem is the CommitOrderNodeCalculator not knowing about sub-class dependencies.

@doctrinebot commented on GitHub (Jun 6, 2010): Comment created by @beberlei: Attached a test-case that verifies this bug exists. Problem is the CommitOrderNodeCalculator not knowing about sub-class dependencies.
Author
Owner

@doctrinebot commented on GitHub (Jun 7, 2010):

Issue was closed with resolution "Fixed"

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

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/e6884ff3bf41ef83a5a5

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/e6884ff3bf41ef83a5a5 - [10628_DDC599Test.php](https://gist.github.com/e6884ff3bf41ef83a5a5#file-10628_DDC599Test-php)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#735