Q:

How can be changed operation order while flush

Can I change sql execution order while flush in Doctrine.
Mysql has well-known bug. This statements may cause deadlock
INSERT INTO operations(id, user_id) VALUES(null, 123);

UPDATE users SET user_name = 'name' WHERE id = 123;

Deadlock found when trying to get lock; try restarting transaction
So, I what to change order while flushing, update then insert. How can I do this?
Documentation says that order is predefined

1) All entity insertions 2) All entity updates 3) All collection
  deletions 4) All collection updates 5) All entity deletions

https://www.doctrine-project.org/api/orm/2.7/Doctrine/ORM/UnitOfWork.html
But how I can change this order?

A:

It cannot be changed. If you faced with this problem you need create your own transaction. And flush update, then flush insert manually.

