实现分页的时候代码是
public List<BBS> getBBS(String sql){
ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
sessionFactory=ctx.getBean("sessionFactory",SessionFactory.class);
Session session = sessionFactory.openSession();
Query query=session.createQuery("from BBS order by b_id desc");
query.setMaxResults(2);
query.setFirstResult(0);
List<BBS> list=query.list();
return list;
}
但是运行结果报错
org.hibernate.exception.SQLGrammarException: could not extract ResultSet
把
query.setMaxResults(2);
query.setFirstResult(0);
去掉之后,就好了,这要怎么解决啊?