Resolving mongodb links in spring

Suppose I have the following documents in mongodb in an employee collection:

db.employees.insert({_id: ObjectId("4d85c7039ab0fd70a117d733"), name: 'Siona',
manager: [ObjectId("4d85c7039ab0fd70a117d730"), ObjectId("4d85c7039ab0fd70a117d732")] })

Here, "Siona" has two managers listed in the managers array. I know that Spring Data M3 has the concept of DBRefs, but the monogdb documentation indicates that DBrefs are expensive, and that we should just store the ObjectId whenever possible.

My question is, is there any way to resolve the document pointed to by the objectID object via the Spring Data Document api, or am I forced to make a client-side connection, where:

  • We get a document that has a name: "Siona"
  • Return to the database to enable each ObjectId that represents the Siona managers.
+5
source share
1 answer

Posted by the same question in Spring forums, and one of their community members replied:

http://forum.springsource.org/showthread.php?113968-resolving-simple-mongodb-references-in-spring-wo-dbref

We must do this ourselves on the client side if we do not use dbref.

+3
source

All Articles