title: Error: Class ...\Entity\.. has no association named
body: <p>This question is related to my another question: <a href="https://stackoverflow.com/questions/10450707/doctrine2-gives-me-only-first-instance-of-related-objects">Doctrine2 gives me only first instance of related objects </a></p>
  
  <p>I came up with bidirectional association to try solve my old issue but now I have another problem.</p>
  
  <p>Schema <strong>[EDITED]</strong>:</p>
  
  <pre><code>  XYZ\Bundle\CitiesBundle\Entity\Cities:
    type: entity
    table: cities
    fields:
      id:
        id: true
        type: integer
        unsigned: false
        nullable: false
        generator:
          strategy: IDENTITY
      name:
        type: string
        length: 50
        fixed: false
        nullable: false
      landarea:
        type: decimal
        nullable: false
      density:
        type: integer
        unsigned: false
        nullable: false
      population:
        type: integer
        unsigned: false
        nullable: false
    manyToOne:
      state:
        targetEntity: States
        cascade: {  }
        inversedBy: cities
        joinColumn:
          state_id:
            referencedColumnName: id
    lifecycleCallbacks: {  }
  </code></pre>
  
  <p>Entities:</p>
  
  <pre><code>class Cities
  {
      //other vars
  
      /**
       * @var XYZ\Bundle\CitiesBundle\Entity\States
       */
      private $state;
  
      //other get/set    
  
      /**
       * Set state
       *
       * @param XYZ\Bundle\CitiesBundle\Entity\States $state
       */
      public function setState(\XYZ\Bundle\CitiesBundle\Entity\States $state)
      {
          $this-&gt;state = $state;
      }
  
      /**
       * Get state
       *
       * @return XYZ\Bundle\CitiesBundle\Entity\States 
       */
      public function getState()
      {
          return $this-&gt;state;
      }
  }
  
  class States
  {
      //other vars and get/set
  
      private $cities;
  
      public function __construct()
      {
          $this-&gt;cities = new \Doctrine\Common\Collections\ArrayCollection();
      }
  
      /**
       * Add cities
       *
       * @param XYZ\Bundle\CitiesBundle\Entity\Cities $cities
       */
      public function addCities(\XYZ\Bundle\CitiesBundle\Entity\Cities $cities)
      {
          $this-&gt;cities[] = $cities;
      }
  
      /**
       * Get cities
       *
       * @return Doctrine\Common\Collections\Collection 
       */
      public function getCities()
      {
          return $this-&gt;cities;
      }
  }
  </code></pre>
  
  <p>QueryBuilder usage:</p>
  
  <pre><code>    $query = $em-&gt;createQueryBuilder()
                  -&gt;select('c','s')
                  -&gt;from('CitiesBundle:Cities', 'c')
                  -&gt;innerJoin('c.state', 's')
                  -&gt;orderBy('c.population', 'DESC')
                  -&gt;setMaxResults(10)
                  -&gt;getQuery();  
  </code></pre>
  
  <p>and an error is:</p>
  
  <blockquote>
    <p>[Semantical Error] line 0, col 58 near 's ORDER BY c.population':
    Error: Class XYZ\Bundle\CitiesBundle\Entity\Cities has no association
    named state</p>
  </blockquote>
  
  <p>generated DQL:</p>
  
  <blockquote>
    <p>SELECT c, s FROM CitiesBundle:Cities c INNER JOIN c.state s ORDER BY
    c.population DESC</p>
  </blockquote>
  
  <p>shame :(</p>
  
  <p>Could someone help me solve my issue?</p>
  
  <p>[EDIT]</p>
  
  <p>I edited cities schema, now error is:</p>
  
  <blockquote>
    <p>Notice: Undefined index: name in
    /home/marek/devel/sf2/cities/vendor/doctrine/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
    line 473</p>
  </blockquote>