Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Spring数据在java.util.List中插入$currentDate_Java_Mongodb_Spring Data - Fatal编程技术网

使用Spring数据在java.util.List中插入$currentDate

使用Spring数据在java.util.List中插入$currentDate,java,mongodb,spring-data,Java,Mongodb,Spring Data,我需要进行更新,并在使用spring data mongodb的文档中使用mongo操作符$currentDate。问题是,我无法遍历元素 例如: 错误: Write failed with error code 16837 and error message 'cannot use the part (list of list.someDate) to traverse the element(...) 有人知道解决方案或解决方法吗? Obs。日期必须是MongoDb日期,我不能使用Jav

我需要进行更新,并在使用spring data mongodb的文档中使用mongo操作符$currentDate。问题是,我无法遍历元素 例如:

错误:

 Write failed with error code 16837 and error message 'cannot use the part (list of list.someDate) to traverse the element(...)
有人知道解决方案或解决方法吗? Obs。日期必须是MongoDb日期,我不能使用Java日期,我不能使用这个:

update.set("lista.dataAlteracao", DateTime.now())

您的错误与日期无关

更多的查询/代码无法识别如何访问someDate,您所说的someDate位于列表中。 阅读一点关于位置运算符的内容,在这种情况下,它是救世主

您可能需要稍微更改代码以包含以下内容
列表。$.someDate


您能否发布文档的外观,以便我能给您更好的答案。

您的错误与日期无关。更多的是,您的查询/代码无法识别如何访问列表中的某个日期。阅读一些关于位置运算符的内容,在这种情况下,它是一个救世主。您可能需要稍微更改代码,以包含类似list.$.someDate的内容。你能发布你的文档的样子吗?这样我可以给你一个更好的答案。列表。$。someDate成功了!请在答案上加上这个,这样我可以选择你作为最好的答案谢谢。很乐意帮忙:)作为答案发布。请接受
update.set("lista.dataAlteracao", DateTime.now())