为什么账号密码跟数据库的数据都一样但是显示密码错误,控制台没有报错误,也生成了sql语句
dao层的主要代码:
public class EmployeeDaoImpl implements EmployeeDao {
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
@Override
public Employee findByUsAndPw(Employee employee) {
// TODO Auto-generated method stub
String hql="from Employee where username=? and password=?";
Session session=sessionFactory.getCurrentSession();
Transaction tx=session.beginTransaction();
Query query=session.createQuery(hql);
query.setParameter(0, employee.getUsername());
query.setParameter(1, employee.getPassword());
List <Employee> list=query.list();
/*
* 这里存在Hibernate版本的问题 抽时间弄
*
*/
tx.commit();
if(list.size()>0){
return list.get(0);
}
return null;
}
}
我用的是Hibernate3怎么也是这样啊
用的是Hibernate4