symfony - Doctrine - A new entity was found through the relationship -
since 2 weeks, having problem while trying flush new elements:
critical: doctrine\orm\orminvalidargumentexception:
a new entity found through relationship 'comment#capture' not configured cascade persist operations entity
but capture
in database, , getting findoneby
, if cascade persist it, or persist it, a
table constraint violation: duplicate entry.
the comments created in loop differents captures, new, , required field set.
with of entities persisted , / or got findone
(and valid), flush still fails.
i'm on issue since while, please me
i had same problem , same entitymanager
. wanted insert object related manytoone
. , don't want cascade
persist
.
example :
$category = $em->find("category", 10); $product = new product(); $product->setcategory($category) $em->persist($product); $em->flush();
this throws same exception me.
so solution :
$category = $em->find("category", 10); $product = new product(); $product->setcategory($category) $em->merge($product); $em->flush();