title: Dynamically sorting a NamedQuery? Seam/Hibernate/JPA
body: <p>I have several <code>NamedQuery</code>'s defined, and I'd like to be able to sort on a field for an entity dynamically, without having to create unique <code>NamedQuery</code>'s for each field I want to sort on.  For example:</p>
  
  <p>I have an entity called MyObject, with fields 'a', 'b', and 'c'.  My base query is "<code>SELECT DISTINCT o FROM MyObject o</code>", but I'd like to be able to add an <code>ORDER BY</code> clause to my query.  Ideally, I'd be able to do something like named parameters, where my query would look like:</p>
  
  <pre><code>SELECT DISTINCT o FROM MyObject o ORDER BY :order
  </code></pre>
  
  <p>I would then specify the field (a, b, c) that I want to sort on.  Is there any way to accomplish this using Seam/Hibernate/JPA?  Is there a better strategy for tackling this?</p>