title: how to write order by and limit query in jpa
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6708085/select-top-1-result-using-jpa">Select top 1 result using JPA</a>  </p>
  </blockquote>
  
  
  
  <p>i wish to fetch top 10 results based on 'totalTradedVolume' filed of my table 'MasterScrip'
  when i write the following query:</p>
  
  <pre><code>Collection&lt;MasterScrip&gt; sm=null;
     sm=em.createQuery("select m from MasterScrip m where m.type = :type order by m.totalTradedVolume limit 2").setParameter("type", type).getResultList();
  </code></pre>
  
  <p>i get the following exception :</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: 
  Exception Description: Syntax error parsing the query [select m from MasterScrip m where m.type = :type order by m.totalTradedVolume limit 2], line 1, column 78: unexpected token [limit].
  Internal Exception: NoViableAltException(80@[])
  </code></pre>
  
  <p>something's wrong with my jpa query. can anyone pls correct me?</p>