【问题标题】:Hibernate error node to be traverse cannot be null要遍历的休眠错误节点不能为空
【发布时间】:2014-06-11 14:09:49
【问题描述】:

大家好,我对这个恼人的错误有疑问。下面是我的代码

String updateDefaultBU = "update ClientUserVO  set defaultBUnit = :yes where id = (select      max(cu1.id) from ClientUserVO cu1 where cu1.user.id = :userId and cu1.defaultBUnit = :no)";
updateDefaultBU = " and not exists (select cu2.id from ClientUserVO cu2 where cu2.user.id    = :userId and cu2.defaultBUnit = :yes) ";
Query updateQuery = session.createQuery(updateDefaultBU);
updateQuery.setString("yes", "Y");
updateQuery.setString("no", "N");
updateQuery.setLong("userId", userID);

我似乎不明白它在哪里找到无法遍历的 not,而且这个错误非常普遍,可能由于各种原因发生,你能告诉我我做错了什么吗?

谢谢

【问题讨论】:

    标签: java sql-server hibernate


    【解决方案1】:

    在您对updateDefaultBU 的第二次分配中,您完全更改了变量的内容,而不是与第一次分配连接(我假设您想要这样做)。

    您可能会收到错误,因为您运行 updateQuery.setString("no", "N") 但第二个赋值中没有 :no 值。

    尝试将第二行更改为updateDefaultBU.concat(" <your string> ")

    您是否也尝试过调试以查看错误发生的确切位置?

    【讨论】:

    • 我之前有点着急,是的,连接问题是导致该错误的原因。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2011-08-14
    • 1970-01-01
    • 2018-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-19
    • 2019-11-28
    相关资源
    最近更新 更多