como escrever a ordem e limitar a consulta em jpa [duplicado]
Duplicata Possível:
Selecione o resultado do primeiro resultado usando JPA
Gostaria de obter os 10 melhores resultados com base no campo 'totalTradedVolume' da minha tabela 'MasterScrip' quando escrevo a seguinte 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();
Eu recebo a seguinte exceção:
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@[])
algo está errado com minha consulta jpa. Alguém pode me corrigir?