Database Reference
In-Depth Information
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—torepresentandinteractwith(thatis,readandpersist)variousdomainmodel
concepts.
Though that approach is extremely powerful and flexible, operating with the low-level
Neo4jAPIscansometimesbequiteverboseandresultinalotofboilerplatecode,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 develop-
ment 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 andusedinotherchaptersthroughoutthebook.Thisisthesocialnetworkexample
that allows users to rate movies. We'll use this social network to demonstrate how SDN al-
lows 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.
9.1. Where does SDN fit in?
In a nutshell, SDN is an object-graph mapping (OGM) framework that was created to make
life easier for (currently only Java) developers who need, or would prefer, to work with a
POJO-based domain model, where some or all of the data is stored in Neo4j. It aims to in-
crease productivity by dealing with all the low-level plumbing and mapping logic required
to read domain entities from and write them back into Neo4j. This should free you to focus
Search WWH ::




Custom Search