报错:
org.springframework.orm.hibernate3.HibernateQueryException: lbook is not mapped [select count(*) from lbook]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: lbook is not mapped [select count(*) from lbook]
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:639)
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:377)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:840)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:832)
com.joyque.test.dao.impl.LbookDAOImpl.findPageByHQL(LbookDAOImpl.java:51)
com.joyque.test.service.impl.LbookServiceImpl.search(LbookServiceImpl.java:39)
com.joyque.test.action.LbookAction.findAllBook(LbookAction.java:52)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
我的代码:
/*
* HQL语句的分页查询
* (non-Javadoc)
* @see com.joyque.test.dao.LbookDAO#findPageByHQL(com.jouque.test.util.Page)
*/
@SuppressWarnings("unchecked")
public Page findPageByHQL(Page page) {
int currentPage=page.getCurrentPage();
int pageSize=page.getPageSize();
String hql="from lbook";
long a1=System.currentTimeMillis(); //获得的是自1970-1-01 00:00:00.000 到当前时刻的时间距离,类型为long
page.setAllRow((Integer)this.getHibernateTemplate().find("select count(*) from lbook").get(0));
long a2=System.currentTimeMillis();
System.out.print("this.getHibernateTemplate().find(hql).size()查询总记录数用的时间:"+(a2-a1));
page.setTotalPage(Page.countTotalPage(pageSize, page.getAllRow()));
Session session=(Session)this.getHibernateTemplate().getSessionFactory().getCurrentSession();
long a3=System.currentTimeMillis();
Query query= session.createQuery(hql);
int pagenum =(currentPage-1)*pageSize;