Each call to Doctrine\ORM\EntityManager#flush enclosed in a transaction.
This means that if your current RDBM supports transactions , ORM will automatically START TRANSACTION , and then perform all the necessary queries, and then either COMMIT if everything goes fine, or ROLLBACK if an error occurs.
You can learn more about how Doctrine 2 ORM handles transactions and concurrency in the documentation.
source share