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

这是错误:[WARN]SQLError:1064,SQLState:420002012-12-1904:45:29org.hibernate.util.JDBCExcep... 这是错误:
[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();
}

}); }
在线急求,分不够可以加!
展开
 我来答
mskycn
2012-12-19 · 超过19用户采纳过TA的回答
知道答主
回答量:86
采纳率:0%
帮助的人:75.2万
展开全部
from where (maid=23 )and(lseffect=0 ) order by restime desc limit 5

form 后面要加表名吧
追问
from MationComments where maid=23 and lseffect=0 order by restime desc

这个是打印的HQL语句 有的 不知道为什么hibernate打印出来就少了表名了
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式