【发布时间】:2012-05-30 07:51:40
【问题描述】:
我希望根据我的表“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 查询有问题。谁能纠正我?
【问题讨论】:
-
查看我对类似问题的回答stackoverflow.com/questions/6708085/…
-
它并不是真正的重复。类似的问题检索任意结果,这个问题是关于获取 m.totalTradedVolume 值最高的结果。
标签: java jpa persistence