Are there that many circumstances where you could potentially end up with a closed entity manager? The importing situation sure, but in other circumstances I would expect validation to occur before you persist the entity.
For an importer where you are processing lots of junk data and may encounter issues that take too much time or effort to properly validate beforehand, could dropping back to DBAL to do the required queries be a solution? I dont see any real solution for reusing a closed entity manager, but I think this problem at least needs a best practice because the question will come up over and over again when users come across this issue and cant validate beforehand (or, imo, more likely dont want to). t On Mar 26, 7:46 pm, Lukas Kahwe Smith <[email protected]> wrote: > On 26.03.2011, at 10:43, Lukas Kahwe Smith wrote: > > > So when a transaction does fail the only solution is to effectively make a > > totally new EntityManager according to Benjamin. > > > Now if you use Container injecting this is less of a problem (though still > > problem, more below). If you don't, you basically need to not only make the > > new instance, but you also need to magically find out all the places that > > follow the failed transaction (DB logger, rendered form with DB filled > > choice fields. > > > Now if you do inject the Container everywhere and never assign it to a > > class property all you have to do is reset the service. However this is > > less trivial than you might think because of service aliasing: > > > // reset the EM and all aias > > $container->set('doctrine.orm.entity_manager', null); > > $container->set('doctrine.orm.default_entity_manager', null); > > // get a fresh EM > > $em = $this->container->get('doctrine.orm.entity_manager'); > > I should add when not injecting the Container I obviously also shouldn't need > to know the name of the service, which makes the above code even harder. > > regards, > Lukas Kahwe Smith > [email protected] -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en
