symfony - Doctrine 2: Not all entities get persisted, why? -
i'm trying persist feedback entities in loop. problem is, 1 entity doesn't persisted (no matter how many entities want persist @ all; it's n-1 instead of n).
to understand following code snippet have know survey entity can contain several feedback entities (1..n relation).
let's if $feedbackcount = 10 9 feedback entities persisted database. @ end of post can see according doctrine unit of work. shows 10 feedback entities added to survey (so loop working right) 9 feedback entities listet @ end.
any ideas guys?
here's code:
for ($count = 0; $count < $feedbackcount; $count++) { $feedback = new feedback(); $feedback->setfeedback("no feedback yet"); $feedback->setsurvey($survey); // add feedback survey $survey->addfeedback($feedback); // persist feedback $entitymanager->persist($survey); // persist($feedback) has same effect } // end $uof = $entitymanager->getunitofwork(); dump($uof);
here's unit of work of dump statement:
here yaml entity configs of...
feedback:
manytoone: survey: targetentity: app\apibundle\entity\survey inversedby: feedbacks cascade: ["persist"] joincolumn: name: surveyid referencedcolumnname: id
survey:
onetomany: feedbacks: targetentity: app\apibundle\entity\feedback cascade: ["persist", "merge"] mappedby: survey
update:
as asked malcom, following screenshot shows within arraycolletion feedback entity(0) has same properties feedback entity(1). there no difference. (irrelevant properties blurred)
solution:
see last comment.
Comments
Post a Comment