title: JPA, playframework, select order by before group by
body: <p>How can I write a query in "JPA" 
  that will ORDER BY before the GROUP BY?</p>
  
  <p>For example :</p>
  
  <pre><code>select m from Message m where m.id = (
    select distinct m2.conversation_id
      from Message m2
     where m2.from = 100 or m2.to = 100
  )
  group by m.conversation_id order by m.date desc
  </code></pre>
  
  <p>I want the last (most recent) messages for each conversation id.</p>