title: JPA select List<Object> from entity order by list elements attribute
body: <p>Im having a self reffering datamodel. Im trying to get a list of children ordered by an attribute using JPA (Hibernate). But Im having problems with the JPQL. Do you have a suggestion on how I can solve this?</p>
  
  <p><strong>Entity</strong></p>
  
  <pre><code>@Entity
  public class Foo {
      private String bar;
      private List&lt;Foo&gt; elements;
  } 
  </code></pre>
  
  <p><strong>JPQL</strong></p>
  
  <p>Demo JPQL to give you a hint of what Im trying to do</p>
  
  <pre><code>String jpql = "SELECT f.elements " +
                "FROM Foo f " +
                "Order By f.elements.bar";
  </code></pre>