【发布时间】:2017-07-21 13:37:15
【问题描述】:
我是 Mongo 和 Ws02 DSS 的新手。下面是我编写的更新操作,用于更新 Mcongo 的 llection 中名为“inventory”的现有文档。
<query id="mongoUpdate" useConfig="localMongo1">
<expression>inventory.update({"itemId":"3"},{"currentStock" :"2"})</expression>
<param name="itemId" sqlType="STRING"/>
</query>
虽然所有简单的操作都运行良好,但我得到了下面的更新嵌套异常:
java.lang.IllegalArgumentException:传递给查询的参数过多:{“currentStock”:“2”}
为简单起见,我在没有使用我创建的参数的情况下进行了硬连接,但更新仍然不起作用。有人可以帮忙吗?
【问题讨论】:
-
你能显示一个get查询的结果吗?
-
> db.inventory.find() { "_id" : ObjectId("596e79ad60b934a369266524"), "itemId" : "1", "itemName" : "Television-4k", "unitPrice" : “1400”,“currentStock”:“77”} {“_id”:ObjectId(“596e79bf60b934a369266525”),“itemId”:“2”,“itemName”:“笔记本电脑”,“unitPrice”:“400”,“currentStock” ":"53"} {"_id":ObjectId("596e7dad7353e34606463c37"),"itemId":"4","itemName":"冰箱","unitPrice":"700","currentStock":"23"} {“_id”:ObjectId(“596ef6327353e33b264b506c”),“itemId”:“3”,“itemName”:“Mobile”,“unitPrice”:“400”,“currentStock”:“2”}
-
添加查询:
和操作:inventory.find() -
如果你删除
<param name="itemId" sqlType="STRING"/>部分,你会得到同样的错误吗? -
当我从查询和操作的调用查询中删除参数时,硬编码更新运行良好。只有当我使用参数时,它才会抛出“传递给查询的参数过多:{currentStock:'3'}”。
我不知道为什么会这样。inventory.update({itemId:'3'}, {currentStock : '3'})