getHibernateTemplate()的查询问题(已解决)
我想根据username来查询纪录,然后删除:public void delete(String username) {
String QueryUserByUsername = "from User u where u.username=:"+username;
List list = getHibernateTemplate().find(QueryUserByUsername);
User user = (User)list.get(0);
getHibernateTemplate().delete(user);
}
User有以下属性:id,username,age,address,job
但是总报错:
EVERE: Servlet.service() for servlet action threw exception
org.springframework.orm.hibernate3.HibernateQueryException: Not all named parameters have been set: [Bob] [from User u where u.username=:Bob]; nested exception is org.hibernate.QueryException: Not all named parameters have been set: [Bob] [from User u where u.username=:Bob]
org.hibernate.QueryException: Not all named parameters have been set: [Bob] [from User u where u.username=:Bob]
可能是我的hql语句不对。请问应该怎么写才能正常查询啊?谢谢~~~
[[italic] 本帖最后由 hwoarangzk 于 2007-12-28 16:14 编辑 [/italic]]