可能重复:
使用 JPA 选择前 1 个结果
当我编写以下查询时,我希望根据我的表“MasterScrip”的“totalTradedVolume”字段获取前 10 个结果:
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();
我得到以下异常:
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@[])
我的 jpa 查询有问题。谁能纠正我?