title: How to dynamically order many-to-many relationship with JPA or HQL?
body: <p>I have a mapping like this:</p>
  
  <pre><code>@ManyToMany(cascade = CascadeType.PERSIST)
      @JoinTable(
              name="product_product_catalog",
              joinColumns={@JoinColumn(name="product_catalog", referencedColumnName="product_catalog")},
              inverseJoinColumns={@JoinColumn(name="product", referencedColumnName="product")})
      public List&lt;Product&gt; products = new ArrayList&lt;Product&gt;();
  </code></pre>
  
  <p>I can fetch the products for the catalog nicely, but I can't (dynamically) order the products.
  How could I order them?
  I probably have to write a many-to-many HQL query with the order-by clause? I though of passing the orderBy field name string to the query, or is there a better solution?</p>
  
  <p>Tables are:
  products,
  product_catalog,
  product_product_catalog (associative table)</p>
  
  <p>P.S. Using Play! Framework JPASupport for my entities.</p>