Gabriel Gabriel - 6 months ago 39
Java Question

Insert $currentDate in java.util.List using Spring-data

I need to make an update and use the mongo operator $currentDate in a document I am using spring-data-mongodb the problem is, I can't traverse the element

Update update = new Update();
update.set("list", listOfObjects);


Write failed with error code 16837 and error message 'cannot use the part (list of list.someDate) to traverse the element(...)

Someone know a solution or some workaround?
Obs. The date must be the MongoDb date, I can't use the Java date, I can't use this:



Your error is not related to date.

its more of your query/code is not able to identify how to access someDate which you are saying is sitting inside list. read a bit about positional operator and in such cases it is a savior.

you probably need to change your code a bit to include something like list.$.someDate.

can you post how your document looks like so that i can give you a better answer.