0
我有這樣的代碼,它不工作:代理對象失敗的設置屬性,必須得到實際的對象
$em = $this->container->get('doctrine.orm.entity_manager');
$accountObj->setHasCheckpoint(1);
$em->flush();
,我必須做到以下幾點:
$em = $this->container->get('doctrine.orm.entity_manager');
$user = $em->getRepository('UserBundle:User')->findOneById($accountObj->getId());
$user->setHasCheckpoint(1);
$em->flush();
爲了得到檢查點被設置。爲什麼是這樣? accountObj只是另一個$entity->getUser();
的可能的複製[設置Doctrine2實體屬性而無需檢索整個關聯的對象] (http://stackoverflow.com/questions/13007843/set-doctrine2-entity-property-without-retrieving-entire-associated-object) –