Answer the question
In order to leave comments, you need to log in
How to fix cascade persist?
I have two entities
class Orders{
/**
* @ORM\OneToMany(targetEntity=Positions::class, mappedBy="ord",cascade={ "remove",
"persist"})
*/
private $positions;
}
class Positions{
/**
* @ORM\ManyToOne(targetEntity=Orders::class, inversedBy="positions")
* @ORM\JoinColumn(name="ord",referencedColumnName="guid",onDelete="CASCADE")
*/
private $ord;
}
class OrdersRepository{
public function delOrder(){
....
$this->em->remove($order);
$this->em->flush();
}
}
A new entity was found through the relationship 'App\Entity\Positions#ord' that was not configured to cascade persist operations for
entity: App\Entity\[email protected] To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist
this association in the mapping for example @ManyToOne(..,cascade={"persist"}). If you cannot find out which entity causes the problem implement '
App\Entity\Orders#__toString()' to get a clue.
class OrdersRepository{
public function delOrder(){
....
$this->em->remove($order);
$this->em->flush();
$this->em->clear(); //?????? верно ли, почему помогло?
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question