【发布时间】:2015-08-01 12:22:47
【问题描述】:
在我的休眠查询中,我有:
public void updateStudent(Student student) {
String hql = "update Student set article =:null,id=2"
+"where article=:"+ student.getArticle();
sessionFactory.getCurrentSession().createQuery(hql);
}
这里我想设置student表的article value=null and id=2..但是
every time an error is occurring:
node to traverse cannot be null!
Caused by:
java.lang.IllegalArgumentException: node to traverse cannot be null!
我实际的mysql查询是:
UPDATE student
SET article='null', id=2
WHERE article='xyz'; here xyz=user.getArticle()
我做错了什么??
【问题讨论】:
-
我认为不需要:null,只要写null和where子句中的文章一样。
-
你能给我正确的结构吗??
-
以下是向查询传递参数的方法:docs.jboss.org/hibernate/orm/4.3/manual/en-US/html_single/…。阅读文档后,一切都会变得简单得多。
标签: java hibernate spring-mvc hql