mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Question: Why are all inserts executed when single entity is committed? #5777
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ossinkine on GitHub (Nov 21, 2017).
Originally assigned to: @Ocramius on GitHub.
According to UnitOfWork.php#L512 the all insertions will be executed even I want to commit single entity.
It looks doubtful. See example:
@Ocramius commented on GitHub (Nov 21, 2017):
$entityManager->flush($someData);is to be avoided. We removed support for the parameters being passed toflush()exactly because it was a performance optimisation that just caused more problems than what it solved.@ossinkine commented on GitHub (Nov 23, 2017):
Guys, you are guru of DDD and of other cool things, give me an advice.
I want to keep separately my Doctrine entities and Domain models according to persistence ignorance practice.
My business logiс should work with models and domain managers (which can create and update models), and domain managers should work with entities or documents or something else.
What is your opinion, is it a good way?
If yes, where flush method should be called considering that different domain managers can use different storage?
@lcobucci commented on GitHub (Nov 24, 2017):
@ossinkine if you're using a service bus to encapsulate the execution of handlers (what you're calling a "domain manager") you can use a middleware that would start the transaction and call the
flush()after things were processed (if you don't have an exception, sure).With that your handlers should simple use the repositories to fetch/append/remove objects and modify the object state to update data.
@lcobucci commented on GitHub (Nov 24, 2017):
I'll be closing this issue since it has already been answered by @Ocramius but feel free to continue with the off-topic =)