別のオブジェクトの属性であるオブジェクトを削除したいのですが、これを実行すると、「エンティティが見つかりませんでした」という例外が発生します。</ p>
私が言っていることの例:
// Foo has a private property, bar, which is an instance of Bar
$foo = $this->get('my_bundle.repository.foo')->find($fooId);
$bar = $foo->getBar();
$entityManager = $this->get('doctrine.orm.entity_manager');
$entityManager->remove($bar);
$entityManager->flush();
Bar
これは、以下が機能しているように見えるため、エンティティマネージャがのインスタンスを直接ロードしなかったためだと思います。
// Foo has a private property, bar, which is an instance of Bar
$foo = $this->get('my_bundle.repository.foo')->find($fooId);
$bar = $this->get('my_bundle.repository.foo')->find($bar->getId());
$entityManager = $this->get('doctrine.orm.entity_manager');
$entityManager->remove($bar);
$entityManager->flush();
リロードせずにこれを機能させる方法はあり$bar
ますか?