Posted on 2007-04-23 15:11
samfree 阅读(2205)
评论(5) 编辑 收藏
我在用hibernate对mysql进行分页的方法
/**
* 函数说明:获得所有的信息
* 参数说明:
* 返回值:信息的集合
*/
public List getProducts(final int pageSize, final int startRow) throws HibernateException {
return this.getHibernateTemplate().executeFind(new HibernateCallback(){
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query query=session.createQuery("FROM Products as p");
query.setMaxResults(pageSize);
query.setFirstResult(startRow);
List list = query.list();
return list;
}
});
}
运行时怎么老给出异常阿?请帮帮我看看好吗?
org.springframework.orm.hibernate3.HibernateJdbcException: JDBC exception on Hibernate data access; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
org.hibernate.exception.SQLGrammarException: could not execute query
java.sql.SQLException: Syntax error or access violation, message from server: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '40 products0_.game_id as game1_0_, products0_.game_name_en as game2_0_, products' at line 1"