Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleMongoRepository.findById(id, class) don't return ids for nested documents. [DATAMONGO-1050] #1971

Closed
spring-projects-issues opened this issue Sep 9, 2014 · 2 comments
Assignees
Labels
in: repository type: bug

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Sep 9, 2014

Konstantin Petrukhnov opened DATAMONGO-1050 and commented

SimpleMongoRepository.findById(id, class) don't return ids for nested documents.

E.g.

class A {
 private String id; //stored in mongo as "id"
 private String name;
}

class B {
  private String id; // stored in mongo as "_id"
  private List<A> innerDocs;
}

When it return B documents, innerDocs A objects have id == null. If i refactor A.id to A.myId, then it start working correctly.

Saving data (save, updateFirst, etc) always save fields correctly.

A and B objects are pojos (only lombok @Data and @NoArgsConstructor is used to provide getters and setters). Ids are created by mongo.

Could it related somehow to ids that have 24 characters, but stored not as "_id"?

Easy workaround is to have different field name (not "id").


Affects: 1.5.1 (Dijkstra SR1), 1.6 GA (Evans)

Referenced from: pull request #225

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Oct 23, 2014

Thomas Darimont commented

This should be fixed in master now, could you give it a try?

We'll have a look on backporting this to 1.6.x and 1.5.x

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Oct 30, 2014

Thomas Darimont commented

Please revise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: repository type: bug
Projects
None yet
Development

No branches or pull requests

2 participants