I am trying to remove a ManyToMany relationship inside Doctrine 2. I have two entities - User
and TargetGroup
.
In my User
entity I have:
/**
* @ORM\ManyToMany(targetEntity="TargetGroup", inversedBy="users")
*/
private $targetGroups;
In my TargetGroup
entity I have:
/**
* @ORM\ManyToMany(targetEntity="User", mappedBy="targetGroups")
*/
private $users;
I am trying to call:
$user->removeTargetGroup($targetGroup);
$targetGroup->removeUser($user);
$em->persist($user);
$em->persist($targetGroup);
$em->flush();
The two methods used are:
public function removeTargetGroup(Path To Bundle $targetGroups)
{
$this->targetGroups->removeElement($targetGroups);
}
public function removeUser(Path To Bundle $users)
{
$this->users->removeElement($users);
}
It does not error, but it does not do any of the delete queries either.
Any suggestions?