Hibernate或者ssh三大框架中出现 XXXX is not mapped问题

来源:互联网 发布:windows微信是什么 编辑:程序博客网 时间:2024/06/10 23:17

Hibernate或者ssh三大框架中出现 XXXX is not mapped问题微笑


错误异常信息:
org.springframework.orm.hibernate3.HibernateQueryException: loginUser is not mapped [from loginUser order by userId]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: loginUser is not mapped [from loginUser order by userId]
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:664)
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:912)
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:904)
com.data.dao.LoginMapDao.getAll(LoginMapDao.java:14)
com.data.service.LoginService.getAll(LoginService.java:20)
com.data.action.LoginAction.list(LoginAction.java:40)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

.......................................................


错误原因是这样的:

public List<Person> queryAllResulit() {// TODO Auto-generated method stub//这里的表面必须是和实体类中的类名是一样的,而不是和数据库表名一样String hql ="from person";List<Person> listperson = this.getHibernateTemplate().find(hql);return listperson;}

解决方案分析:你所查询的表名,是数据库的表。实际上这里要写实体类名(ssh中称持久化类名)

你改成你的实体类名就好了


0 0