title: Doctrine 2: OneToMany Relation, order by foreign key
body: <p>I have three entities (<code>Profile</code>, <code>ProfileValue</code> and <code>Value</code>).<br>
  A <code>Profile</code> has a one-to-many relation with <code>ProfileValue</code>, which has a many-to-one relation with the <code>Value</code> entity.</p>
  
  <p>Is it possible to get the rleated <code>ProfileValues</code> from the <code>Profile</code>, ordered by the <code>value id</code>?</p>
  
  <p>If I add the <code>orderby</code> annotation for a non-foreign-key like the enabled field in <code>ProfileValue</code>, it works. But for a foreign key, it failed with the message <em><code>"inrecognized field"</code></em>. Any ideas?</p>
  
  <pre class="lang-php prettyprint-override"><code>/**
   *
   * @ORM\Table(name="profile")
   * @ORM\Entity
   */
  class Profile {
  
      /**
       * @var integer $id
       *
       * @ORM\Column(name="id", type="integer", nullable=false, options={"unsigned"=true})
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="IDENTITY")
       */
      private $id;
  
      /**
       * @var array $profileCValues
       * @ORM\OneToMany(targetEntity="ABC\XYZBundle\Entity\ProfileValue", mappedBy="profile", cascade={"persist"})
       * @ORM\OrderBy({"value" = "ASC"})
       */
      private $profileValues;
  </code></pre>
  
  <p>And here is the <code>ProfileValue</code> entity:</p>
  
  <pre class="lang-php prettyprint-override"><code>/**
   * ABC\XYZBundle\Entity\ProfileValue
   *
   * @ORM\Table(name="profile_value", indexes={@ORM\Index(columns={"profile_id"}), @ORM\Index(columns={"value_id"}) })
   * @ORM\Entity
   */
  class ProfileValue {
      /**
       * @var integer $id
       *
       * @ORM\Column(name="id", type="integer", nullable=false, options={"unsigned"=true})
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="IDENTITY")
       */
      private $id;
  
      /**
       * @var integer $enabled
       *
       * @ORM\Column(name="enabled", type="boolean", length=1, nullable=true)
       */
      private $enabled;
  
      /**
       * @var ABC\XYZBundle\Entity\Profile
       * @ORM\ManyToOne(targetEntity="ABC\XYZBundle\Entity\Profile", inversedBy="profileValues")
       * @ORM\JoinColumn(name="profile_id", referencedColumnName="id", nullable=true, onDelete="CASCADE")
       */
      private $profile;
  
      /**
       * @var ABC\XYZBundle\Entity\Value
       * @ORM\ManyToOne(targetEntity="ABC\XYZBundle\Entity\Value")
       * @ORM\JoinColumn(name="value_id", referencedColumnName="id", onDelete="CASCADE")
       */
      private $value;
  }
  </code></pre>