Hibernate是如何自动生成SQL语句的,这里SQL语句为什么只写一半就能查出结果来?
publicUsergetUserbyLoginInfo(Stringname,Stringpassword){Sessionsession=sessionFactory...
public User getUserbyLoginInfo(String name, String password) {
Session session = sessionFactory.openSession();
String hql = "FROM User AS u WHERE u.name = :name AND u.password = :password";
Query q = session.createQuery(hql);
q.setString("name", name);
q.setString("password", password);
List<User> list = q.list();
session.close();
if (list.size()==0)
return null;
else
return list.get(0);
} 展开
Session session = sessionFactory.openSession();
String hql = "FROM User AS u WHERE u.name = :name AND u.password = :password";
Query q = session.createQuery(hql);
q.setString("name", name);
q.setString("password", password);
List<User> list = q.list();
session.close();
if (list.size()==0)
return null;
else
return list.get(0);
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询