Hi Menno, On 16 October 2014 15:23, Holtkamp <[email protected]> wrote:
> Suppose I got the following Entities > > A => one-to-many => B > B => many-to-one => C > > Then let's > > 1. load an instance of A: $a > 2. given $a, iterate over the collection of B's: > 3. pick a specific B: $b. For that specific B: > 4. given $b, change the instance of C ($c1), with another, already > existing / managed instance of C ($c2) > > > After flushing, I would expect that the join- column of the table for > Entity B referring to Entity C would be updated from $c1.id to $c2.id > > But instead: > > - when invoking $entityManager->flush(); the value of the column > in'b.c_id' does not change (seems the change is not detected) > - when invoking $entityManager->flush($b); the value of the column > in'b.c_id' does change (the change is detected) > > And as experiment: > > - when invoking $entityManager->flush($a); the value of the column > in'b.c_id' does not change (the change is not detected) > > I thought that $entityManager->flush() would check its internal Identity > Map for all 'dirty' / changes objects and flush them. But it appears the > change to Entity B as part of the collection in Entity A is not detected. > > Has that behavior changed recently, or is my assumption incorrect, can't > remember I ever needed to explicitly invoke flush on a specific kind of > Entity... > > Cheers, > > Menno > > PS, the reason I am asking is because we are using DCI > <http://en.wikipedia.org/wiki/Data,_context_and_interaction> inspired > UseCases that should only return a boolean. After a successfull execution > of a UseCase the controller invokes $entityManager->flush(). Now I have to > do $entityManager->flush($b); inside the UseCase (we should not return the > $b to the controller), while the UseCase is purely functional and should > not care about such details. > > From what I read here, you simply didn't update the owning side of the association. You should really abstract this example you just described in words into a small integration test like the ones that can be found at https://github.com/doctrine/doctrine2/tree/35d44057275f010e1a7d5fd400c4dfdd446eb9ab/tests/Doctrine/Tests/ORM/Functional/Ticket, as a test case speaks for more than a thousand words in this case. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
