开发者

hql equivalent query to this sql query

开发者 https://www.devze.com 2022-12-22 01:34 出处:网络
Select top 1 fr开发者_如何学编程om <tablename> what is hql query for the above ?Just write a normal query, ans use \"SetMaxResult\" to limit your results.
Select top 1 fr开发者_如何学编程om <tablename>

what is hql query for the above ?


Just write a normal query, ans use "SetMaxResult" to limit your results.

I.e.

return  getSession().createQuery("from items order by id asc")
            .setMaxResults(1)
            .list();


It seems you must use the setMaxResults() method.

See for example this question+answer : How do you do a limit query in HQL


You'll probably want to use the setMaxResults of the Query Object.

To my knowledge, HQL does not support top or limit.

0

精彩评论

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

关注公众号