SSH整合报错
org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped [select count(*) from User u where u.userName=? and u.userPassword=? ]
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped
实现类是这么写的:
@Component("userDAOImpl")
public class UserDAOImpl implements UserDAO {
private final String LOGIN_HQL = "select count(*) from User u where u.userName=? and u.userPassword=? ";
private HibernateTemplate hibernateTemplate;
@Resource(name = "hibernateTemplate")
public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
this.hibernateTemplate = hibernateTemplate;
}
@Override
public String login(User user) {
String flag = null;
Session session = hibernateTemplate.getSessionFactory().openSession();
long result = (Long) session.createQuery(LOGIN_HQL)
.setString(0, user.getUserName())
.setString(1, user.getUserPassword())
.uniqueResult();
if (result > 0)
flag = "success";
else
flag = "fail";
return flag;
}
}
配置文件和Model类没有问题,数据库也是用正向工程自动生成的,但是运行的时候说匹配不上User,这是为什么????
诚心求教,望大神指点 展开
错误一:org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [spring.xml]; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
解决办法:aopalliance.jar
错误二:java.lang.NoClassDefFoundError: org/springframework/expression/PropertyAccessor
解决办法:加上spring-expression-3.2.9.RELEASE.jar
错误三:nested exception is java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Around
解决办法:加入aspectjweaver.jar
错误四:nested exception is java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ReflectionManager
解决办法:加入hibernate-commons-annotations-4.0.4.Final.jar
错误五:nested exception is java.lang.NoClassDefFoundError: org/jboss/logging/BasicLogger
解决办法:使用Hibernate4.0后,需要引入jboss-logging.GA.jar
错误六:nested exception is java.lang.NoClassDefFoundError: javax/transaction/SystemException
解决办法:加入jboss-transaction-api_1.2_spec-1.0.0.Final.jar
错误七:nested exception is java.lang.NoClassDefFoundError: javax/persistence/Entity
解决办法:加入ejb3-persistence.jar
错误八:nested exception is java.lang.NoClassDefFoundError: javax/persistence/NamedStoredProcedureQuery
解决办法:加入hibernate-jpa-2.1-api-1.0.0.Final.jar