Ask Your Question
4

When using Spring data mongodb, is ObjectId generated during the saving process and String _id generated during updates?

asked 2023-07-12 18:22:29 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-07-12 18:26:02 +0000

djk gravatar image

No, ObjectId is also generated during updates in Spring data mongodb. Spring data mongodb generates an ObjectId by default for each new document inserted into a collection, regardless of whether it is a save or an update operation. However, you can also provide your own custom generated ObjectId for each document by setting the _id field with a value of your choosing before you save or update the document.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-12 18:22:29 +0000

Seen: 14 times

Last updated: Jul 12 '23