title: How do I order an HQL query by a property of an object in a collection?
body: <p>Let's say I have a Car with a Radio and the Radio has a one-to-many association with Button. What I want is the unique names of all of the buttons in cars made by Ford, sorted by Button name. Given the way our relations are set up, I can't figure out how to do this. Something like:</p>
  
  <pre><code>select distinct elements(c.radio.buttons)
  from Car c 
  where c.make = 'Ford'
  order by c.radio.buttons.name
  </code></pre>
  
  <p>The last part is wrong, of course. I'm going to paginate this data so that's why I'm trying to do it entirely in a query.</p>
  
  <p>The answer might involve a join fetch but so far I've had no luck. Thanks!</p>