Duplicar posibles:
Select top 1 result using JPAcómo escribir orden y consulta límite en JPA
deseo a buscar a los 10 mejores resultados basados en 'totalTradedVolume' presentado de mi mesa 'MasterScrip' cuando escribo la siguiente consulta:
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();
me sale el siguiente 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][])
algo anda mal con mi consulta jpa. ¿alguien puede por favor corregirme?
comprobar mi asnwer a una pregunta similar http://stackoverflow.com/questions/6708085/select-top-1 -result-using-jpa/6708151 # 6708151 – Jorge
No es realmente un duplicado. La pregunta similar recupera un resultado arbitrario, esta pregunta se trata de obtener el resultado con el valor más alto para m.totalTradedVolume. –