'Java Spring Data MongoDB
I am using Spring data mongo with azure cosmos. My structure looks like below. I have an Id field in my collection that is not annotated with @Id. I see both _id and id are in the DB but When I retrieve id field comes with the value is in _id.
@Document(collection = "mycollection")
class MyObject{
private String id;
...
}
public interface MyRepository extends MongoRepository<MyObject, Void> {
}
Solution 1:[1]
Used @Field("id") to tell spring data threat this field as is not as _id/pk field for mongo
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | James |
