[英]hibernate query java.lang.IllegalArgumentException: node to traverse cannot be null
In my hibernate query I have : 在我的休眠查询中,我有:
public void updateStudent(Student student) {
String hql = "update Student set article =:null,id=2"
+"where article=:"+ student.getArticle();
sessionFactory.getCurrentSession().createQuery(hql);
}
Here I want to set student table's article value= null and id =2 ..but 在这里我想设置学生表的文章值= null和id = 2 ..but
every time an error is occurring:
node to traverse cannot be null!
Caused by:
java.lang.IllegalArgumentException: node to traverse cannot be null!
my actual mysql query is: 我实际的mysql查询是:
UPDATE student
SET article='null', id=2
WHERE article='xyz'; here xyz=user.getArticle()
what am I doing wrong?? 我究竟做错了什么??
As @JBNizet mentions in the comment, you need to consult the documentation. 正如@JBNizet在评论中提到的那样,您需要查阅文档。 But you need something like this to set your parameter.
但是您需要这样的设置参数。
public void updateStudent(Student student) {
String hql = "update Student set article = null, id = 2"
+ " where article = :article";
sessionFactory.getCurrentSession()
.createQuery(hql)
.setParameter("article", student.getArticle()) ... etc
}
PS I cannot understand why you are setting the id of your Student when you appear to be deleting an article value. 附言:当您似乎要删除文章值时,我无法理解为什么要设置学生ID。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.