liveBook · Manning

Spring Data MongoDB

As explained in Java Persistence with Spring Data and Hibernate epub

Spring Data MongoDB is a Spring Data module that provides repository-oriented access to MongoDB document data.

Spring Data MongoDB provides a repository-oriented way for Java applications to access MongoDB document databases. It follows the Spring Data model of repositories, object-mapping abstractions, annotations, derived queries, Spring integration, and Spring Boot configuration. section 17.0 section 17.2

A typical application can use Spring Data MongoDB to:

  • Configure a Spring Boot project with the MongoDB starter and application properties. section 17.2
  • Create MongoRepository interfaces with derived queries, result limits, sorting, paging, and streaming. section 17.7
  • Use @Query, Query by Example, or MongoTemplate when repository methods are insufficient. section 17.7

Mapping a User document

A User class can be annotated with @Document and @Id, index username with @Indexed, declare compound indexes with @CompoundIndexes, exclude password with @Transient, and mark a retrieval constructor with @PersistenceConstructor. Lombok annotations can generate constructors, getters, and setters.

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Covers project configuration, document mapping, indexes, repository queries, MongoTemplate CRUD, and alternative query techniques.
Examples
Uses a CaveatEmptor User document with identifiers, indexes, transient fields, persistence constructors, repositories, and MongoTemplate operations.
What it assumes
Assumes core Java, basic Spring, Maven, and REST familiarity while teaching MongoDB persistence through Spring Data abstractions.
What you can do after
Build it from scratch by configuring Spring Boot, mapping documents, defining repository queries, and selecting MongoTemplate when needed.
How it connects
Connects MongoDB document mapping with Spring Boot, MongoRepository, MongoTemplate, derived queries, and Query by Example.

Also explained in

Compare how 2 books explain Spring Data MongoDB →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Java Persistence with Spring Data and Hibernate epub. The section links point to the parts of the book it draws on.