Chapter 9. Spring Data Neo4j
This chapter covers
- Creating a domain model using Spring Data Neo4j (SDN)
- Loading and saving your SDN domain entities
- Object-graph mapping modes work within SDN
- Performing queries with SDN
Until now we’ve been working directly with the core Neo4j graph primitives—nodes and relationships—to represent and interact with (that is, read and persist) various domain model concepts.
Though that approach is extremely powerful and flexible, operating with the low-level Neo4j APIs can sometimes be quite verbose and result in a lot of boilerplate code, especially when it comes to working with domain model entities. In this chapter we’ll introduce you to Spring Data Neo4j (SDN), a subproject within the broader Spring Data project that aims to bring the convenience of working with the simpler, more familiar Spring-based development model to the NoSQL world, and in this case, specifically to Neo4j.
To demonstrate SDN, we’ll be returning to the social network example first described in chapter 1 and used in other chapters throughout the book. This is the social network example that allows users to rate movies. We’ll use this social network to demonstrate how SDN allows for the domain to be modeled using plain old Java objects (POJOs), and we’ll explain how the mapping to the underlying graph structure occurs. We’ll also demonstrate how to read, persist, and query these managed entities.