title: Doctrine orderBy annotation. Ordering Entity associations based on an associated Entity.
body: <p>Say have the following entities with a Symfony app.</p>
  
  <pre><code>class List
  {
      /**
       * @ORM\OneToMany(targetEntity="ListItem", mappedBy="list")
       * @ORM\OrderBy({"category.title" = "ASC"})
       */
      protected $listItems;
  }
  
  class ListItem
  {
      /**
       * @ORM\ManyToOne(targetEntity="List", inversedBy="listItems")
       */
      protected $list;
  
      /**
       * @ORM\ManyToOne(targetEntity="Category", inversedBy="listItems")
       */
      protected $category;
  }
  
  class Category
  {
      /**
       * @ORM\OneToMany(targetEntity="ListItem", mappedBy="cateogory")
       */
      protected $listItems;
  
      protected $title;
  }
  </code></pre>
  
  <p>The orderBy argument, <code>category.title</code> unfortunately will not work in doctrine. My understanding is that the most common solution is to store an extra property on the <code>ListItem</code> Entity such as <code>$categoryTitle</code> and using this new field in the orderBy annotation. For example;</p>
  
  <pre><code>class List
  {
      /**
       * @ORM\OneToMany(targetEntity="ListItem", mappedBy="list")
       * @ORM\OrderBy({"categoryTitle" = "ASC"})
       */
      protected $listItems;
  }
  
  class ListItem
  {
      // --
  
      protected $categoryTitle
  }
  </code></pre>
  
  <p>The problem with this approach is the extra overhead of keeping this <code>$categoryTitle</code>, up to date through set methods and/or listeners, and obviously the denormalization of database data.</p>
  
  <p>Is there a method I can use to order this association with doctrine, without degrading the quality of my database?</p>