title: Doctrine2: order associated entity by property of another entity related to it
body: <p>Let A, B, C be associated entities. I'm aiming for <code>A-&gt;getBs()</code> to return a collection of <code>B</code> ordered by two properties: <code>B.createdAt</code> and <code>B.C.displayOrder</code>.</p>
  
  <p>First works fine, second does not: I've tried <code>"c.displayOrder" = "asc"</code>, but this has been unsuccessful (<code>Unrecognized field: c.displayOrder</code>).</p>
  
  <p>Is there any way to order by a property from another related entity?</p>
  
  <p>The other option I could imagine is overriding the function <code>getBs()</code>, but I wouldn't know how to create a custom DQL query in there to accommodate for my special need. I've read that using the EntityManager inside an Entity is bad practice.</p>
  
  <pre><code>A
  /**
    * @ORM\OneToMany(targetEntity="B", mappedBy="a")
    * @ORM\OrderBy({"createdAt" = "asc", "c.displayOrder" = "asc"})
    */
  -id
  -getBs()
  
  
  B
  /**
   * @ORM\ManyToOne(targetEntity="A")
   * @ORM\JoinColumn(referencedColumnName="id")
   */
  
  /**
   * @ORM\ManyToOne(targetEntity="C")
   * @ORM\JoinColumn(referencedColumnName="id")
   */
  -id
  -createdAt
  
  C
  -id
  -description
  -displayOrder
  </code></pre>
  
  <p>Using doctrine/orm v2.4.5, symfony-standard-edition 2.3.20</p>