title: beginTransaction in symfomy2
body: <p>I'm learning and I have more doubts about Doctrine and Symfony</p>
  
  <p>What is the best practice for persist?
  Now i'm using this:</p>
  
  <pre><code>try {
          $em = $this-&gt;getEm();
          $em-&gt;beginTransaction();
          $product = new \Acme\StoreBundle\Entity\Product();
          $product-&gt;setName('foo');
          $product-&gt;setPrice('19.99');
          $em-&gt;persist($product);
          $em-&gt;flush();
          $em-&gt;commit();
      } catch (\Exception $e) {
          $em-&gt;rollback();
          throw $e;
      }
  </code></pre>
  
  <p>But In symfony documentation, there isn't beginTransaction.
  And What is the different between  <code>$em = $this-&gt;getDoctrine()-&gt;getManager();</code> <code>$em = $this-&gt;getDoctrine()</code>? When to use one or the other </p>