doctrine2 - Doctrine: does an entity manager update in memory relations before flushing changes? -


suppose have 2 classes (person, house) bidirectional relationship (a person has list of houses , house has owner).

suppose had following in person class:

$houses = new arraycollection();  public function removehouse(id){     $this->houses->remove(id); } 

suppose had person (with name: john) owns house , did following:

$john = $em->find('user', $johnsid); $johnshouse = $john->gethouse(0); // give john's first house  echo $house->getowner()->getname(); // echo "john"  $user->removehouse(0); // remove house john's list  echo $house->getowner()->getname();  

this before entity manager flushes anything. first question: last echo produce? null or "john"

then flush occurs...

$em->flush();  echo $house->getowner()->getname();  

second question: echo produce now? null or john?

from understand doctrine's documentation, should produce null, right?

my goal have other side of bidirectional relation reflect change occurred on side before flushing occurs. put differently, want echo of first question produce null.

if isn't done automatically entity manager before flushing (answer first question "john"), do have fix performing update on other side manually modding removehouse function?

public function removehouse(id){     $house = $this->houses->remove(id);     $house->setowner(null) } 

and there complications have when entity manager attempts make changes upon flushing?

i've discovered answers questions after stumbling upon right page in documentation. you, developer, required keep relations in sync yourself.

see: http://docs.doctrine-project.org/en/2.0.x/reference/working-with-associations.html


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -