String hql="select top 10 * from article as a where a.articleType=1"
+" order by a.clicks desc";
结果发现:这样写会报错,那么利用hql应该怎么查询前10条数据呢,我就郁闷了。
事先声明:不用Criteria;
用Spring的this.getHibernateTemplate()某个方法返回结果集。
等待高人解答~~~~~
+" order by a.clicks desc";
结果发现:这样写会报错,那么利用hql应该怎么查询前10条数据呢,我就郁闷了。
事先声明:不用Criteria;
用Spring的this.getHibernateTemplate()某个方法返回结果集。
等待高人解答~~~~~
但MYSQL的SQL语法中不是使用TOP的,而是用LIMIT
select * from article as a where a.articleType=1 order by a.clicks desc limit 10
session.createQuery("from Article where articleType=1").setFirstResult(0).setMaxResults(10);