Spring Data MongoDB Examples

In this tutorial we will look about some examples of Spring Data - MongoDB integration. How to Spring configure with NoSQL database and what the advantages of this we will explain in this chapter.

Getting started with MongoDB and Spring Data -
The primary goal of the Spring Data project is to make it easier for developers to work with (No)SQL databases. The Spring Data project already has support for a number of  NoSQL type of databases.

Spring Data for MongoDB is part of the umbrella Spring Data project which aims to provide a familiar and consistent Spring-based programming model for for new datastores while retaining store-specific features and capabilities. The Spring Data MongoDB project provides integration with the MongoDB document database. Key functional areas of Spring Data MongoDB are a POJO centric model for interacting with a MongoDB DBCollection and easily writing a Repository style data access layer.

Spring Data


Spring Data makes it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services as well as provide improved support for relational database technologies.
Spring Data is an umbrella open source project which contains many subprojects that are specific to a given database. The projects are developed by working together with many of the companies and developers that are behind these exciting technologies.

Features


There are below the list of Spring Data and MongoDB examples. Spring Data for MongoDB examples to perform insert, update, query and delete documents from MongoDB.

1. Spring Data MongoDB hello world example
Configure (both XML and annotation) and perform CRUD operations with “Spring Data for MongoDB” framework.

2. Spring Data MongoDB : Insert document
Example to use Spring data save(), insert() and insertList() to save domain object into mongoDB database.

3. Spring Data MongoDB : Update document
Example to use Spring data save(), updateFirst() and updateMulti() to update existing domain object from mongoDB database.

4. Spring Data MongoDB : Query document
Example to use Spring data findOne(), find() and getCollection() to get / query documents from mongoDB.

5. Spring Data MongoDB : Delete document
Example to remove() and findAndRemove() to delete document from mongoDB.


References

  1. MongoDB official site
  2. Java MongoDB official tutorials
  3. Java development with MongoDB
  4. Spring data for MongoDB
  5. Spring data for MongoDB documentation



Labels: