Eventuali duplicati:
Select top 1 result using JPACome scrivere ORDER BY e interrogazione limite JPA
desidero per andare a prendere primi 10 risultati sulla base di 'totalTradedVolume' depositato del mio tavolo 'MasterScrip' quando scrivo la seguente query:
Collection<MasterScrip> sm=null;
sm=em.createQuery("select m from MasterScrip m where m.type = :type order by m.totalTradedVolume limit 2").setParameter("type", type).getResultList();
ottengo il seguente exc eption:
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([email protected][])
qualcosa non va con la mia query jpa. Qualcuno può correggermi?
leggi la mia asnwer a una domanda simile http://stackoverflow.com/questions/6708085/select-top-1 -result-using-jpa/6708151 # 6708151 – Jorge
Non è proprio un duplicato. La domanda simile recupera un risultato arbitrario, questa domanda riguarda l'ottenimento del risultato con il valore più alto per m.totalTradedVolume. –