How to make EntityManager's flush method to flush only certain entity instances? #11051
Replies: 1 comment
-
Side-note: you only have to call For your problem: you can access the Unit-of-work (which contains all pending operations) via Guess thats a semi-helpful answer, sorry for that :/ |
Beta Was this translation helpful? Give feedback.
-
Hi!
My issue is that EntityManager's flush method is writing in the database all the operations buffered by the persist method. No problem with that, BUT sometimes changes get written in other context (deeper layers of my symfony app) without me knowing about it. Let me show you an example:
The EntityManager flushes everything, then my problem is that sometimes deep services are flushing changes done in other layers of my app without me noticing. So far it has not been a problem for me, but I can see a design problem here (on my side).
How do you tackle this issue? Do you have any design idea to apply to sort this out. Or, is there any way to wrap only certain operations within the flush method so it only writes in the DB the operations of the context?
Ideally I would like to have this behaviour in the previous code:
I imagine something like this as a solution to accurate the operations that the Entity flushes:
Maybe to make some EntityManager as a not shared service?
Beta Was this translation helpful? Give feedback.
All reactions