title: How to get object in different translations with Doctrine and Gedmo Translatable Extension
body: <p>I'm stuck with the following problem: I want to fetch doctrine entities of a specific locale without breaking the default behavior of my Symfony app.</p>
  
  <p>Here is an example of one of my entity:</p>
  
  <pre><code>use Doctrine\ORM\Mapping as ORM;
  use Gedmo\Mapping\Annotation as Gedmo;
  
  /**
   * @ORM\Entity(repositoryClass="ProductRepository")
   * @ORM\Table(name="product")
   * @ORM\InheritanceType("SINGLE_TABLE")
   * @ORM\DiscriminatorColumn(name="discr", type="string")
   */
  class Product
  {
      /**
       * @var integer $id
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      protected $id;
  
      /**
       * @var string
       * @ORM\Column(name="name", type="string")
       * @Gedmo\Translatable
       */
      protected $name;
  
      // ...
  }
  </code></pre>
  
  <p>The a part of related doctrine repository:</p>
  
  <pre><code>class ProductRepository extends \Doctrine\ORM\EntityRepository
  {
      public function findOneProductInLocale($id, $locale)
      {
          $qb = $this-&gt;createQueryBuilder('p')
              -&gt;select('p')
              -&gt;where('p.id = :id')
              -&gt;setMaxResults(1)
              -&gt;setParameter('id', $id);
          ;
  
          $query = $qb-&gt;getQuery();
  
          $query-&gt;setHint(
              \Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER,
              'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'
          );
  
          // force Gedmo Translatable to not use current locale
          $query-&gt;setHint(
              \Gedmo\Translatable\TranslatableListener::HINT_TRANSLATABLE_LOCALE,
              $locale
          );
  
          $query-&gt;setHint(
              \Gedmo\Translatable\TranslatableListener::HINT_FALLBACK,
              1
          );
  
          return $query-&gt;getOneOrNullResult();
      }
  }
  </code></pre>
  
  <p>and a part of my scripts:</p>
  
  <pre><code>// default Locale: en
  // request Locale: de
  $repo = $em-&gt;getRepository('Acme\\Entity\\Product');
  
  $product1 = $repo-&gt;findOneById($id);
  echo $product1-&gt;getName(); // return 'Name (DE)'
  
  $product_de = $repo-&gt;findOneProductInLocale($id, 'de');
  echo $product_de-&gt;getName(); // return 'Name (DE)';
  
  $product_en = $repo-&gt;findOneProductInLocale($id, 'en');
  echo $product_en-&gt;getName(); // return 'Name (EN)'
  
  echo $product1-&gt;getName(); // return 'Name (EN)' instead of 'Name (DE)' !! &lt;-- What is wrong?
  
  // even if I refetch a product
  $product2 = $repo-&gt;findOneById($id);
  echo $product2-&gt;getName(); // return 'Name (EN)' without taking anymore in account the current locale
  </code></pre>
  
  <p>Is someone now why this didn't work as expected ?
  Is something wrong in my implementation of <code>ProductRepository::findOneProductInLocale()</code> ?</p>
  
  <p>Any help or hint is welcome.</p>