问题描述
- 关于hibernateTemplate的问题
-
首先我的查询语句是这样写的:=====》
return this.getHibernateTemplate().find("from bean.Customer");
然后报这个错:====》
org.springframework.orm.hibernate3.HibernateQueryException: bean.Customer is not mapped [from bean.Customer]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: bean.Customer is not mapped [from bean.Customer]
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:657)
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:921)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:913)
com.sxt.dao.CustomerDao.findAll(CustomerDao.java:47)
====这个47行就是我的那个查询语句
解决方案
Customer映射的不对
解决方案二:
CustomerDao里的查询方法和映射的查询方法不同,可以是参数,或名,或返回值
解决方案三:
from bean.Customer 改成 from Customer
解决方案四:
HibernateTemplate空指针的问题
时间: 2024-08-08 04:24:52