一个简单的hibernate hql语句获取对象记录

public User findUserByCon(String username, String passwd, boolean enabled) {

String hql ="from User u where 1=1 and u.username =:username and u.password=:password and u.enabled = :enabled";

String[] param = {"username","password","enabled"};

Object[] values = {username,passwd,enabled};

List<User> userList = this.getHibernateTemplate().findByNamedParam(hql, param, values);

if(userList!=null && userList.size()>0){

return userList.get(0);

}else{

return null;

}

}


你可能感兴趣的:(一个简单的hibernate hql语句获取对象记录)