1

I'll put my question simple, so excuse me...

Does Spring Data MongoDB support dot-notation in update queries?

I've tried to execute this snipet:

Query query = new Query(Criteria.where("_id").is(id));
Update update = new Update();
update.set("value.version",version);
mongoOperations.updateFirst(query, update, Audit.class);

And found no expected changes in Audit collection. What am I missing?

1
  • dot notation should work properly in spring-data. I tested here and successfully update a field using dot notation. Are you sure that exists an document with the id? Commented Jul 8, 2013 at 12:38

1 Answer 1

1

My mistake was that I didn't realize that id in is() part of query criteria must be ObjectId. For some reason Spring Data does automatic conversion from ObjectId to BigInteger, but not from BigInteger to ObjectId.

If someone knows how to convert it manually, please answer this question

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.