DDC-1157: Remove Cascade doesn't work on proxy object #1451

Closed
opened 2026-01-22 13:14:59 +01:00 by admin · 2 comments
Owner

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

Originally assigned to: @guilhermeblanco on GitHub.

Jira issue originally created by user benoit:

Hi all,

I am a beginner with doctrine, so all my apologize if this is not the place, or if this issue was already report. I posted on doctrine user google group(http://tinyurl.com/6gh49yh), but got no response, asked on mirc channel, not response too. I searched into jira for the same issue, but i don't find.

This is my problem: I have a ont-to-one relation between two entities, A and B. A got foreign key to B. I configure delete cascade on A, so i am expected that if A is deleted, B should be too.
I used the Entity Manager getReference method to get an A entity, so this is a proxy object. I did $em->remove($A). After flush, A is remove, but B still alive.
I investigate doctrine source code, and i found in UnitOfWork#cascaseRemove method, line 1705, a TODO comment line, where initialized should call on proxy object. And when remove is called on Proxy object, at this point, $relatedEntities is null.
When i used the Entity Manager find method, i got an object fullfilled, so at this line $relatedEntities is not null.

So this is a forgotten implementation, a bug, or did I make something wrong because what i want to do work perfectly for you ?

Thanks for reading.

Originally created by @doctrinebot on GitHub (May 18, 2011). Originally assigned to: @guilhermeblanco on GitHub. Jira issue originally created by user benoit: Hi all, I am a beginner with doctrine, so all my apologize if this is not the place, or if this issue was already report. I posted on doctrine user google group(http://tinyurl.com/6gh49yh), but got no response, asked on mirc channel, not response too. I searched into jira for the same issue, but i don't find. This is my problem: I have a ont-to-one relation between two entities, A and B. A got foreign key to B. I configure delete cascade on A, so i am expected that if A is deleted, B should be too. I used the Entity Manager getReference method to get an A entity, so this is a proxy object. I did $em->remove($A). After flush, A is remove, but B still alive. I investigate doctrine source code, and i found in UnitOfWork#cascaseRemove method, line 1705, a TODO comment line, where initialized should call on proxy object. And when remove is called on Proxy object, at this point, $relatedEntities is null. When i used the Entity Manager find method, i got an object fullfilled, so at this line $relatedEntities is not null. So this is a forgotten implementation, a bug, or did I make something wrong because what i want to do work perfectly for you ? Thanks for reading.
admin added the Improvement label 2026-01-22 13:14:59 +01:00
admin closed this issue 2026-01-22 13:15:00 +01:00
Author
Owner

@doctrinebot commented on GitHub (Sep 6, 2011):

Comment created by @guilhermeblanco:

Defining delete cascade means that when B is removed, A is also removed... not the opposite.

You need to define cascade={"remove"} in order to have this working nicely.

@doctrinebot commented on GitHub (Sep 6, 2011): Comment created by @guilhermeblanco: Defining delete cascade means that when B is removed, A is also removed... not the opposite. You need to define cascade={"remove"} in order to have this working nicely.
Author
Owner

@doctrinebot commented on GitHub (Sep 6, 2011):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Sep 6, 2011): Issue was closed with resolution "Invalid"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1451