
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();
}
}); }
在线急求,分不够可以加! 展开
[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();
}
}); }
在线急求,分不够可以加! 展开
1个回答
展开全部
from where (maid=23 )and(lseffect=0 ) order by restime desc limit 5
form 后面要加表名吧
form 后面要加表名吧
追问
from MationComments where maid=23 and lseffect=0 order by restime desc
这个是打印的HQL语句 有的 不知道为什么hibernate打印出来就少了表名了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询