On 19.04.2011, at 14:40, merk wrote: > 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?
Another issue is when for performance reasons you cannot do a read with lock before doing the write. In this scenario, which is likely to occur on web applications (where as the importer is likely a CLI script in most cases) where one needs to gracefully be able to still produce some proper output. > 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). The issue with the EntityManager is of course that all in memory instances referenced to that EntityManager are sort of lost, which however is fine in most cases for a web application. Aka you have an action which causes a rollback fine. But there might be other layers that have not yet been triggered, which therefore also do not have any references to Entities managed by that EntityManager which get triggered afterwards, which now also fail. Aka there is no reason why I cannot create a new entity and store it after the rollback. Either Doctrine could support this somehow. Or we could achieve this by having a proxy service that is injected and which has a method to replace the current EntityManager instance with a fresh one. Now obviously in my rollback code I can always do this myself. However for this to be manageable at all it means: 1) the code following kinda needs to be using container injection 2) the code doing the recreation of the EntityManager needs some easy way to determine all alias's for the given EntityManager service 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
