一個簡單的hibernate hql語句獲取對象記錄

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

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

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

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

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

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

return userList.get(0);return

}else{ab

return null;

}

}

相關文章
相關標籤/搜索