title: Symfony2: transactions fail with "There is no active transaction."
body: <p>I've spend several hours trying to resolve this issue. Google and Stackoverflow didn't help much either. So any advice is most welcome here.</p>
  
  <p>I'm trying to apply a rollback logic with transactions when updating two tables in relation:</p>
  
  <p>The code in general is:</p>
  
  <pre><code>// ...
  $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
  $em-&gt;getConnection()-&gt;beginTransaction();
  
  foreach($dataArr as $data) {
      $userObj = $em-&gt;getRepository('AcmeBundle:User')-&gt;find($userId);
      $userObj-&gt;setActive(1);
      $em-&gt;persist($userObj);
      $em-&gt;getConnection()-&gt;commit();
  }
  
  $storeObj = $em-&gt;getRepository('AcmeBundle:Store')-&gt;find($storeId);
  $storeObj-&gt;setIsOpen(1);
  $em-&gt;persist($storeObj);
  $em-&gt;getConnection()-&gt;commit();
  
  try {
  
      $em-&gt;flush();
      $em-&gt;clear();    
  
  } catch(Exception $e) {
  
      $em-&gt;getConnection()-&gt;rollback();
      $em-&gt;close();
      throw $e;
  
  }
  </code></pre>
  
  <p>My PDO drivers are enabled, updating without transactions works as expected, but once I beginTransaction() and try to commit() nothing works and I get the <strong>There is no active transaction.</strong> exception.</p>
  
  <p>Some sources suggested using only commit() without persist() but it doesn't make any difference. I'm probably doing something really stupid here, but I just cannot see what it is.</p>