DDC-3755: Flushing a single entity does not cascade flushes #4604

Closed
opened 2026-01-22 14:45:48 +01:00 by admin · 1 comment
Owner

Originally created by @doctrinebot on GitHub (Jun 3, 2015).

Originally assigned to: @Majkl578 on GitHub.

Jira issue originally created by user harmar:

I have a bidirectional onetoone entities set up like this

class user

@OneToOne(targetEntity="Address", inversedBy="user",  cascade={"persist"})
$address

class Address

@OneToOne(targetEntity="User", mappedBy="address")
$user

@Column()
$city

Now say I saved a new user

$user = new User();
$address = new Address();
$address->setCity("Chicago");
$user->setAddress($address);
$em->persist($user);
$em->flush($user);

I get the expected result saved to the database.
Now say I want to update the city

$address = $user->getAddress()
$address->setCity("new york");
$user->setAddress($address);
$em->persist($user);
$em->flush($user);

The updated address information does not save even though cascade persist is enabled. I need to do a full flush ($em->flush()) for it to save properly

I would think since it does cascade the insert, that it should also cascade the update?

So Expected result:
Address information is saved to database

Actual Result:
Address information is not saved to the database

Originally created by @doctrinebot on GitHub (Jun 3, 2015). Originally assigned to: @Majkl578 on GitHub. Jira issue originally created by user harmar: I have a bidirectional onetoone entities set up like this class user ``` @OneToOne(targetEntity="Address", inversedBy="user", cascade={"persist"}) $address ``` class Address ``` @OneToOne(targetEntity="User", mappedBy="address") $user @Column() $city ``` Now say I saved a new user ``` $user = new User(); $address = new Address(); $address->setCity("Chicago"); $user->setAddress($address); $em->persist($user); $em->flush($user); ``` I get the expected result saved to the database. Now say I want to update the city ``` $address = $user->getAddress() $address->setCity("new york"); $user->setAddress($address); $em->persist($user); $em->flush($user); ``` The updated address information does not save even though cascade persist is enabled. I need to do a full flush ($em->flush()) for it to save properly I would think since it does cascade the insert, that it should also cascade the update? So Expected result: Address information is saved to database Actual Result: Address information is not saved to the database
admin added the BugWon't Fix labels 2026-01-22 14:45:48 +01:00
admin closed this issue 2026-01-22 14:45:48 +01:00
Author
Owner

@Majkl578 commented on GitHub (Dec 19, 2017):

Single entity is going to be removed in Doctrine 3.0.

@Majkl578 commented on GitHub (Dec 19, 2017): Single entity is going to be removed in Doctrine 3.0.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4604