开发者

EJB-QL exception

开发者 https://www.devze.com 2023-01-10 06:59 出处:网络
select DISTINCT TOP 10o.MaterialNumber from MaterialCreation_MDO o where o.MaterialGroup= ?1 and 开发者_运维问答o.Noun= ?2 and o.MaterialNumber like ?3 order by o.MaterialNumber desc

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

精彩评论

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