public List findAllBook() {
log.debug("finding Book all books");
try {
String strHql="from Book as book";
Query qu=getSession().createQuery( strHql);
qu.setFirstResult(1);
qu.setMaxResults(2);
List results=qu.list();
System.out.println("get the data ending");
return results;
} catch (RuntimeException re) {
log.error("find all books failed", re);
throw re;
}
}
上面的怎么不能得到數(shù)據(jù),本來是分頁的,后來索性來兩個(gè)常數(shù)試一下,不行,不要qu.setFirstResult(1);
qu.setMaxResults(2);
這兩行反而能得到數(shù)據(jù)庫表中的全部數(shù)據(jù),加上什么都沒有,我用的數(shù)據(jù)庫是mysql,異常信息如下:
WARN - SQL Error: 1064, SQLState: 42000
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 '?, ?' at line 1
org.hibernate.exception.SQLGrammarException: could not execute query
這是怎么回事,這個(gè)問題我困惑了我?guī)滋炝耍绻涝蛘?qǐng)發(fā)信息到:zyhlogin@163.com,謝謝了啊!!
回復(fù) 更多評(píng)論