Developing using spring-data-mongodb

From a developer's perspective, when a program needs to interact with a MongoDB instance, they need to use the respective client APIs for their specific platforms. The trouble with doing this is that we need to write a lot of boilerplate code and it is not necessarily object-oriented. For instance, we have a class called Person with various attributes such as name, age, address, and so on. The corresponding JSON document shares a similar structure to this person class as follows:

{
  name:"…",
  age:..,
  address:{lineOne:"…", …}
}

However, to store this document, we need to convert the Person class to DBObject, which is a map with key and value pairs. What is really needed is to let us persist this Person class itself ...

Get MongoDB Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.