0

I have to get the existing id to update user information (e.g. email/name/password). I using POJOs to map the object id. I can see a similar post, but in .Net

How can I do that to pass it to the constructor? (Sorry, I'm very new to MongoDB)

ObjectId _id = request.getParameter("id"); // "erro with Type mismatch: cannot convert from String to ObjectId"


User user = new User(_id, email, fullName, password);
2
  • Your question is lacking quite a lot of content. First of all what is the ObjectId. Aside from that. Pleas share more of your code. Commented Oct 15, 2020 at 13:32
  • @akortex91 sorry, I have another post about update user inform that I think the POJO class might causing this problem. Really sorry for the lack of context. Commented Oct 15, 2020 at 13:58

1 Answer 1

1

can you show the POJO(class) it might be caused by the type you have user in your model for the id...I'm not able to tell you what is the problem but have a look at this link it might help you https://jira.mongodb.org/browse/JAVA-3677

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

10 Comments

I have another related post to this and have more code in it. The POJO I am using is following the quick start tutorial only.
so try to use simple type and see what it will do:
It can't get the the _id that saying something wrong with the autocodec...
Btw, is that possible to get the _id without POJO to map the model?
so try to use simple type and see what it will do: [stackoverflow.com/a/21709825/9936992] so instead of using ojectId read the policy and use simple types and see if it works
|

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.