Doctrine 2 Transaction demarcation: implicit vs explicit <p>Im reading the doctrine 2 docs and have a question about transaction demarcation. Is there any difference between the following two snippets of code (other than syntax obviously)? Or is this just two ways of doing the exact same thing (ie implicitly and explicitly). What is the preferred method/best practice (implicit or explicit)?</p> <p>Implicit:</p> <pre><code>// $em instanceof EntityManager $user = new User; $user-&gt;setName('George'); $em-&gt;persist($user); $em-&gt;flush(); </code></pre> <p>Explicit:</p> <pre><code>// $em instanceof EntityManager $em-&gt;transactional(function($em) { $user = new User; $user-&gt;setName('George'); $em-&gt;persist($user); }); </code></pre>