大家好我对这个恼人的错误有疑问。下面是我的代码
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);
我似乎不明白它在哪里找不到无法遍历的,这个错误也很普遍,可能因各种原因而发生,你能告诉我我做错了什么吗?
谢谢
答案 0 :(得分:0)
在你的updateDefaultBU
的第二个作业中,你正在完全改变变量的内容,而不是与第一个作业连接(我假设你想做)。
您可能会因为运行updateQuery.setString("no", "N")
而收到错误,但第二项作业中没有:no
值。
尝试将第二行更改为updateDefaultBU.concat(" <your string> ")
您是否也尝试过调试以查看错误发生的确切位置?