First off I want to say I've read through all the docs and googled this plenty before posting this question. I know what that error means (un-persisted entity in a relationship)
I'm getting this error where I think I shouldn't be getting it.
I have a OneToMany Bi-Directional relationship as follow:
Class Channel
{
/**
* @ORMOneToMany(targetEntity="Step", mappedBy="channel", cascade={"all"}, orphanRemoval=true)
* @ORMOrderBy({"sequence" = "ASC"})
*/
protected $steps;
}
Class Step
{
/**
* @ORMManyToOne(targetEntity="Channel", inversedBy="steps")
*/
protected $channel;
}
One Channel
can have many Step
s and the owning side is Channel
. After I upgraded from Doctrine 2.4 to 2.5 I'm getting this error:
DoctrineORMORMInvalidArgumentException: A new entity was found
through the relationship 'CompanyMyBundleEntityStep#channel' that
was not configured to cascade persist operations for entity
why is it even finding new relationships from the inverse side? Here's my code:
$channel = new Channel();
$step = new Step();
$channel->addStep($step);
$em->persist($channel);
$em->flush();
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…