Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...