求hql语句(急)

来源:百度知道 编辑:UC知道 时间:2024/06/14 01:08:46
select top 15 * from userinfo
这句sql语句怎么换成hql语句阿?
我想查询数据库中的最后15条记录,这用hql语句怎么写呢?
急,高手帮帮忙啊

from userinfo order by 。。。

userinfo是持久对象的类名

给你个例子吧

//根据空间的id查找指定的条数的数据
public List getListBySizeAndBySpaceId(int size,Long spaceId){
String hqlString ="from TFamilyLeaveMessage t where t.space.id=? order by t.updateTime desc";
return HibernateUtil.currentSession().createQuery(hqlString).setLong(0, spaceId)
.setMaxResults(size).list();
}

我估计lovefeiyiran 的应该可以~