title: symfony transaction commits only one time
body: <p>While using symfony 2.5 with doctrine, I'm trying to start a new transaction for each user, do some work with that user, persist some entities and flush and commit everything at once.</p>
  
  <p>For the first user it's working, All my entities are committed to the database, but the second and so on aren't committed anymore. The commands are executed, but nothing happens in the database.</p>
  
  <pre><code>foreach ($users as $user) {
      $this-&gt;em-&gt;getConnection()-&gt;beginTransaction();
      //Do some stuff
      $this-&gt;em-&gt;persist($user);
      //Do some more stuff
      $this-&gt;em-&gt;persist($organisation);
      //Do even more stuff
      $this-&gt;em-&gt;persist($account);
  
      try {
          $this-&gt;em-&gt;flush();
          $this-&gt;em-&gt;getConnection()-&gt;commit();
      } catch (Exception $e) {
          $this-&gt;em-&gt;getConnection()-&gt;rollback();
          $this-&gt;em-&gt;close();
          throw $e;
      }       
  }
  
  
  /**
   * ICM\IPTVManagerBundle\Entity\User
   *
   * @ORM\Table(name="user")
   * @ORM\Entity(repositoryClass="ICM\IPTVManagerBundle\Repository\UserRepository")
   */
  class User 
  {
      /**
       * @var integer $id
       * @ORM\Column(type = "integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy = "AUTO")
       */
       protected $id;
  
      /**
       * @var string $username
       * @ORM\Column(type = "string", length = 45, unique = true)
       */
      protected $username;
  
      /**
       * @ORM\ManyToOne(targetEntity = "Organisation")
       * @ORM\JoinColumn(name = "organisation_id", referencedColumnName = "id")
       * @Assert\NotNull(groups = {"viewer"})
       */
      protected $organisation;
  </code></pre>
  
  <p>both the user and the organisation are existing entities, only the account is not an existing entitie and need to be created, user and organisation need to be updated.</p>
  
  <p>But... account is not related to user and organisation. That relation is made by hand because multiple entities can have an account and i'm not willing to create an accounttable for each entity.</p>
  
  <p>I need to be able to roll all the database changes back as soon as there is a problem somewhere, but i don't want all the users to be handled and roll back all users if there is a problem with only one of the users.</p>
  
  <p>Can anybody help me? </p>