jak napisać zamówienie według i ograniczyć zapytanie w jpa [duplikat]
Możliwy duplikat:
Wybierz 1 wynik za pomocą JPA
chcę pobrać 10 najlepszych wyników na podstawie „totalTradedVolume” złożonego w mojej tabeli „MasterScrip”, gdy piszę następujące zapytanie:
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();
mam następujący wyjątek:
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@[])
coś jest nie tak z moim zapytaniem jpa. czy ktoś może mnie poprawić?