Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.2k views
in Technique[技术] by (71.8m points)

java - Why retrivied id from mongo body.response was incremented?

I was creating some tests, and I got a problema with mongo _id value.

In a test, I am comparing a default ObjectId generated as follows:

private val defaultPersonId = "507f1f77bcf86cd799439011"

Using it before:

repository.save(Person(ObjectId(defaultPersonId), "Anthony", "Andrade"))

Checking if the document was saved, I see that the ObjectId is the default I created.

enter image description here

But when retrieving through a getForEntity it returns with a different value,

expected: <507f1f77bcf86cd799439011> but was: <507f1f771c2010192fca25b7>
Expected :507f1f77bcf86cd799439011
Actual   :507f1f771c2010192fca25b7

My question is: Why it returns in a different way, and whether it would be possible to return as it is in the mongo.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...