public User user(User user){
this.beginTransaction();
User ruser=new User();
System.out.println(user.getUname());
ruser=(User)this.getSession().createQuery("select aa from User aa where uname= ? and upwd= ?").setParameter(0,user.getUname()).setParameter(1, user.getUpwd()).uniqueResult();
this.endTransaction();
return ruser;
}
可能出现的原因:
1.请务必要注意,在“select aa from User aa where uname= ? and upwd= ?”的时候,这个User,不是你的数据库对应的表名,也不是你的映射文件的表名。而是你的实体对象的名称(是区分大小写的!)。
2.配置文件没有加载到Hibernate的实体类列表里面。
3.映射文件的字段与数据库字段不一致,或者名称不一致。
遇到这个问题的同学可以分别检查一下上面提到的三部分有没有正确。