标签:style class blog code color get
1、使用?通配符
public User validate(String userName, String password) { String hql = "from User u where u.userName = ? and u.password = ?"; User user = null; List<User> list = ht.find(hql, new Object[]{userName, password}); if (list.size()!=0){ user = list.get(0); } return user; }
2、使用键值对应
public User validate(String userName, String password) { String hql = "from User u where u.userName = ? and u.password = ?"; User user = null; List<User> list = ht.find(hql, new Object[]{userName, password}); if (list.size()!=0){ user = list.get(0); } return user; }
Done
Hibernate 带参数查询的两种方式,布布扣,bubuko.com
标签:style class blog code color get
原文地址:http://www.cnblogs.com/xingyyy/p/3809868.html