h4cc / AliceFixturesBundle

A Symfony2 bundle for using Alice and Faker with data fixtures. Abled to use Doctrine ORM as well as Doctrine MongoDB ODM.
MIT License
75 stars 25 forks source link

Working with Doctrine Proxy Objects or References #33

Closed h4cc closed 9 years ago

h4cc commented 9 years ago

There seems to be a problem with doctrine persisting objects referencing already persisted other objects. Occured with 1-N references.

Example code that fixed a usecase:

foreach($entities as $key => $entity) {
  $references[$key] = $manager->getORM()->find(get_class($entity), $entity->getId());
}
h4cc commented 9 years ago

I it really necessary to detach the entites? https://github.com/h4cc/AliceFixturesBundle/blob/master/Fixtures/FixtureManager.php#L162

h4cc commented 9 years ago

The detach() will be removed in the next release. Seemed to be unnecessary anyway.