mysql hql分页查询_hql分页查询信息 一直报SQL语法错误,可是我真找不到了

这是错误:[WARN]SQLError:1064,SQLState:420002012-12-1904:45:29org.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:77)[ERROR]Youhaveanerrorin...

这是错误:

[WARN]SQL Error: 1064, SQLState: 42000

2012-12-19 04:45:29 org.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:77)

[ERROR]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 'from where (maid=23 )and(lseffect=0 ) order by restime desc limit 5' at line 1

2012-12-19 04:45:29 org.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:78)

[WARN]Unhandled Exception thrown: class org.springframework.orm.hibernate3.HibernateJdbcException

2012-12-19 04:45:29 org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:516)

[DEBUG]Closing single Hibernate Session in OpenSessionInViewFilter

2012-12-19 04:45:29 org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:182)

2012-12-19 4:45:29 org.apache.catalina.core.StandardWrapperValve invoke

严重: Servlet.service() for servlet action threw exception

java.sql.SQLException: 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 'from where (maid=23 )and(lseffect=0 ) order by restime desc limit 5' at line 1

这个是HQL语句:from MationComments where maid=23 and lseffect=0 order by restime desc

调用的方法:icommon.findByPage(pageNow*pagesize, pagesize, sqlstr)

private ICommonManagerImpl icommon;

hibernate查询方式是这样:

// hql分页查询信息

public List findByPage(final int start, final int end, final String sql) {

return (List) this.getHibernateTemplate().execute(

new HibernateCallback() {

public Object doInHibernate(org.hibernate.Session session)

throws HibernateException, SQLException {

Query query = session.createQuery(sql);

query.setFirstResult(start);

query.setMaxResults(end);

System.out.println("___"+query);

return query.list();

}

}); }

在线急求,分不够可以加!

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值