您的位置:首页 > 其它

hql 不支持 limit, 替代方法

2013-02-05 21:14 218 查看
public List<User> getUserById(final int userId,final int maxCount,final int firstResult) throws Exception {
final String hql = "from User where userId=? ";
return this.getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(final Session session) throws HibernateException, SQLException {
final Query query = session.createQuery(hql);
query.setParameter(0, userId);
query.setMaxResults(maxCount);
query.setFirstResult(firstResult);
return query.list();
}
});
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: