title: Why does an empty transaction persist my entity (doctrine)?
body: <p>I have a doctrine entity which is being persisted to the database without me ever calling persist or flush.</p>
  
  <p>I've managed to reproduce the problem quite simply below. As you will see, this script loads a row from a database table called MyEntity and obtains a php object with the row's fields as attributes. The script then changes one of the attributes, but does not call persist or flush. Then the script create an empty transaction which does nothing. Oddly, this makes the object persist in the sense that the changes made to the php object are also made in the database. I wouldn't have expected this script to make any changes to the database.</p>
  
  <p>What is happening here?</p>
  
  <p>Note that if I remove the empty transaction, the problem dissapears and no change is made to the database.</p>
  
  <p>Here is the code (<strong>test.php</strong>):</p>
  
  <pre><code>&lt;?php
  
      use Doctrine\ORM\Tools\Setup;
  
      require_once("Doctrine/ORM/Tools/Setup.php");
      Setup::registerAutoloadPEAR();
  
      $classloader = new Doctrine\Common\ClassLoader('testEntities', __DIR__);
      $classloader-&gt;register();
  
      $paths = array();
      $isDevMode = true;
      $config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
      $dbParams = array("driver" =&gt; "pdo_mysql",
          "host" =&gt; "localhost",
          "user" =&gt; "username",
          "password" =&gt; "password",
          "dbname" =&gt; "databaseName",
          "charset" =&gt; "utf8");
  
      $em = \Doctrine\ORM\EntityManager::create($dbParams, $config);
      $em-&gt;getConnection()-&gt;exec("SET NAMES UTF8");
  
      $matches = $em-&gt;getRepository('testEntities\\MyEntity')-&gt;findBy(array('ID' =&gt; 1));
      echo("&lt;pre&gt;");
  
      if (!empty($matches)) {
          $object = $matches[0];
          print_r($object);
          $object-&gt;Content = "WILL IT BLEND?";
          print_r($object);
      }
      $em-&gt;transactional(function($em) {
          // Nothing happens here, but if I comment out the call to transactional, the behaviour of the script changes.
      });
  
      echo("&lt;/pre&gt;Done!");
  ?&gt;
  </code></pre>
  
  <p>Create and fill MyEntity table in the database:</p>
  
  <pre><code>CREATE TABLE `MyEntity` (
    `ID` int(11) NOT NULL AUTO_INCREMENT,
    `Content` varchar(500) COLLATE utf8_swedish_ci NOT NULL,
    PRIMARY KEY (`ID`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci;
  
  INSERT INTO MyEntity (ID, Content) VALUES (NULL, "Hello World");
  </code></pre>
  
  <p>Create MyEntity doctrine Entity (<strong>testEntities\MyEntity.php</strong>):</p>
  
  <pre><code>&lt;?php
  
      namespace testEntities;
  
      /** @Entity @Table(name="MyEntity")*/
      class MyEntity
      {
          /**
           * @Id @GeneratedValue(strategy="AUTO") @Column(type="integer") 
           */
          public $ID;
  
          /**
           * @Column(type="string", length=500)
           */
          public $Content;
      }
  
  ?&gt;
  </code></pre>