title: Cache SELECT query using Doctrine Entity Manager
body: <p>I use Doctrine Entity Manager in my code several times, I used in this way for example:</p>
  
  <pre><code>$em = $this-&gt;getDoctrine()-&gt;getManager();
  $countries = $em-&gt;getRepository('CommonBundle:Country')-&gt;findAll();
  </code></pre>
  
  <p>It's possible to use Doctrine Cache in this format? I see a lot of docs but all of them relative to Doctrine Query Builder, any advice? How to enable cache for <code>SELECT</code> queries?</p>
  
  <p><strong>Caching is not working (tough)</strong></p>
  
  <p>I'm dealing with caching results and I do this in order to cache some queries:</p>
  
  <ul>
  <li><p>Enable APC under <code>orm</code> configuration at <code>config.yml</code>:</p>
  
  <pre><code>doctrine:
      dbal:
          driver:   "%database_driver%"
          host:     "%database_host%"
          port:     "%database_port%"
          dbname:   "%database_name%"
          user:     "%database_user%"
          password: "%database_password%"
          charset:  UTF8
      orm:
          auto_generate_proxy_classes: "%kernel.debug%"
          auto_mapping: true
          metadata_cache_driver: apc
          result_cache_driver: apc
          query_cache_driver: apc
  </code></pre></li>
  <li><p>Attach a repository to my entity:</p>
  
  <pre><code>/**
   * @ORM\Entity(repositoryClass="CommonBundle\Entity\Repository\CountryRepository")
   */
  class Country {
      ....
  </code></pre></li>
  <li><p>Write a method inside repository class for get the data and cache the results:</p>
  
  <pre><code>public function getCountries() {
      $qb = $this-&gt;createQueryBuilder('c');
      $query = $qb-&gt;getQuery();
      $query-&gt;useResultCache(true, 3600, 'countries_cache');
      return $query-&gt;getResult();
  }
  </code></pre></li>
  </ul>
  
  <p>But any time I reload the page the query is executed as shown in the profiler (see picture below):</p>
  
  <p><img src="https://i.stack.imgur.com/DQa1q.png" alt="enter image description here"></p>
  
  <p>What I did wrong? The cache only works for production or also works for development? Should't get cached results instead of query the database once and once?</p>