开发者

EJB-QL exception

select DISTINCT TOP 10 o.MaterialNumber from MaterialCreation_MDO o where o.MaterialGroup= ?1 and 开发者_运维问答o.Noun= ?2 and o.MaterialNumber like ?3 order by o.MaterialNumber desc

this query is throwing exception on encountering 'TOP' keyword in ejb-ql statement....


TOP is unrecognized in EJB-QL, use LIMIT instead.

You can try the below modified query :

select DISTINCT o.MaterialNumber from MaterialCreation_MDO o where o.MaterialGroup= ?1 and o.Noun= ?2 and o.MaterialNumber like ?3 order by o.MaterialNumber desc LIMIT 10;

or alternatively you can give explicitly the number of results to be fetched by :

entityManager.createNativeQuery(query,YourClass.class).setParameter("name",value).setMaxResults(10).getResultList();

NamedQuery will also work fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜