hql等效查询此sql查询

1 sql hql

Select top 1 from <tablename>
Run Code Online (Sandbox Code Playgroud)

什么是上面的hql查询?

Mar*_*ona 5

只需编写一个普通查询,然后使用" SetMaxResult "来限制结果.

return  getSession().createQuery("from items order by id asc")
            .setMaxResults(1)
            .list();
Run Code Online (Sandbox Code Playgroud)