简体   繁体   English

休眠查询java.lang.IllegalArgumentException:要遍历的节点不能为null

[英]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.

相关问题 给出java.lang.IllegalArgumentException的Hibernate查询:遍历的节点不能为null - Hibernate query giving java.lang.IllegalArgumentException: node to traverse cannot be null Spring-data-jpa更新。 java.lang.IllegalArgumentException:遍历的节点不能为null - Spring-data-jpa Update. java.lang.IllegalArgumentException: node to traverse cannot be null java.lang.IllegalArgumentException: uri 不能是 null - java.lang.IllegalArgumentException: uri cannot be null Hibernate Query中的异常-java.lang.IllegalArgumentException - Exception in Hibernate Query- java.lang.IllegalArgumentException java.lang.IllegalArgumentException:迭代变量不能为null - java.lang.IllegalArgumentException: Iteration variable cannot be null ProfileCredentialsProvider:java.lang.IllegalArgumentException:配置文件不能为空 - ProfileCredentialsProvider: java.lang.IllegalArgumentException: profile file cannot be null Instagram Oauth2 java.lang.IllegalArgumentException: authorizationGrantType 不能是 null - Instagram Oauth2 java.lang.IllegalArgumentException: authorizationGrantType cannot be null java.lang.illegalargumentException:无法设置空的TableModel - java.lang.illegalargumentexception:cannot set a null TableModel SWT java.lang.IllegalArgumentException:参数不能为null - SWT java.lang.IllegalArgumentException: Argument cannot be null 1.8.8 java.lang.IllegalArgumentException:插件不能是 null - 1.8.8 java.lang.IllegalArgumentException: Plugin cannot be null
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM