title: Error 'Unknown Entity namespace alias' when using 'CompanyNameBundle:User'
body: <p>I have a strange problem with Symfony2. I'm working on a project with 40-50 entities, and with one of them this code doesn't work:</p>
  
  <pre><code>$user = $em-&gt;getRepository('CompanyUserBundle:User')
      -&gt;findOneBy([
          'username' =&gt; $person-&gt;getUsername()
      ]);
  </code></pre>
  
  <p>I get the error <code>Unknown Entity namespace alias 'CompanyUserBundle'.</code>. The strange thing is that if I change my code to:</p>
  
  <pre><code>$user = $em-&gt;getRepository('Company\UserBundle\Entity\User')
      -&gt;findOneBy([
          'username' =&gt; $person-&gt;getUsername()
      ]);
  </code></pre>
  
  <p>It works perfectly... So, what's wrong here? I'm using the <code>getRepository('Alias:Entity')</code> construction all around the code, and there isn't any other problem...</p>
  
  <p>I don't know if it's important, but <code>User</code> is a child entity from FOSUserBundle <code>BaseUser</code> class.</p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here is my <code>User</code> class (it's located at <code>src/Company/UserBundle/Entity</code>):</p>
  
  <pre><code>namespace Company\UserBundle\Entity;
  
  use FOS\UserBundle\Model\User as BaseUser;
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * User
   *
   * @ORM\Table(name="fos_user")
   * @ORM\Entity
   */
  class User extends BaseUser
  {
      /**
       *
       * @ORM\Id
       * @ORM\Column(type="integer")
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      protected $id;
  
      public function __construct()
      {
          parent::__construct();
          // your own logic
      }
  
     /**
       * Get id
       *
       * @return integer 
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
  }
  </code></pre>
  
  <p>And here a part of my <code>AppKernel.php</code>:</p>
  
  <pre><code>class AppKernel extends Kernel
  {
      public function registerBundles()
      {
          $bundles = array(
              new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
              new Symfony\Bundle\SecurityBundle\SecurityBundle(),
              new Symfony\Bundle\TwigBundle\TwigBundle(),
              /* ... other, non interesting, bundles... */
              new Company\UserBundle\UserBundle(),
              new FOS\UserBundle\FOSUserBundle(),
              new FR3D\LdapBundle\FR3DLdapBundle(),
              new JMS\AopBundle\JMSAopBundle(),
              new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
              new JMS\DiExtraBundle\JMSDiExtraBundle($this),
          );
      }
  }
  </code></pre>
  
  <p>More information: as @herr said in the comments, using</p>
  
  <pre><code>$user = $em-&gt;getRepository('UserBundle:User')
      -&gt;findOneBy([
          'username' =&gt; $person-&gt;getUsername()
      ]);
  </code></pre>
  
  <p>works fine... But I don't understand why. Why in this bundle the namespace alias is <code>UserBundle</code> instead of <code>CompanyUserBundle</code>? I know that this must be a really silly error, but I can't see it...</p>