spring-projects / spring-projects/spring-data-mongodb
Id on nested documents are mapped to _id [DATAMONGO-2496]
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
provirus opened DATAMONGO-2496 and commented
Having the following classes:
@Document
class Parent {
@Id
private String id;
private Child child;
// Getters and setters
}
class Child {
private Long id;
private String name;
// Getters and setters
}
Spring Data produces the following document:
{
"_id": ...,
"child": {
"_id": 10,
"name": "Foo"
}
}
The expected document is:
{
"_id": ...,
"child": {
"id": 10,
"name": "Foo"
}
}
Since there is no need for id mapping on the child document
Affects: 2.2.5 (Moore SR5)
Issue Links:
- DATACMNS-1714 Static Entity Metadata
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the mapping with the Parent and Child classes shown in the issue, comparing the nested document with the expected JSON. Trace the MongoDB mapping path that handles the child’s id and confirm that the parent still uses _id while the nested child retains id. Done means the reported nested output matches the expected document.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, mongodb
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100