- 论坛徽章:
- 0
|
以下是我的代码:
- public LoginForm checkLogin(LoginForm lf) {
- try {
- SessionFactory sf = new Configuration().configure().buildSessionFactory();
- session session = sf.openSession();
- Transaction tx = session.beginTransaction();
- Query query = session.createQuery("select l from LoginForm as l where l.userName = LOGIN and l.password = PASSWORD ");
-
- Iterator results = query.iterate();
- if (results.hasNext()) {
- return (LoginForm) results.next();
- }
-
- tx.commit();
- session.close();
- }
- catch (Exception ex) {
- ex.printStackTrace();
- }
- return lf;
- }
复制代码
这个方法是在用户登陆的时候通过用户输入的用户名和密码(由LoginForm lf传递进来)来通过Hibernate的HQL查询语句来通过到数据库查询是否有此用户来实现用户名和密码的验证.但是现在却起不到作用,什么样的用户名和密码都能进.应该怎么改一下呢,是不是我的HQL语句有问题? |
|