comSysto Blog discusses Spring Data, neo4j, and why Neo4j is a good fit for Spring Data

Today we would like to introduce you to Spring Data Neo4j. To this end we implemented a little showcase application. The context of the showcase is a shop system. Therefore it would be useful to calculate what other users also viewed – as known from many popular shopping e-commerce websites like Amazon. As these connections between users and products are easily displayable as a graph, we decided to use Neo4j to represent the nodes and the relationships between them.

What is Spring Data Neo4j?
First of all, what is Spring Data? It’s a SpringSource project that aims to provide Spring’s programming model and conventions for NOSQL databases. Spring Data supports different NOSQL databases such as Redis, Riak, MongoDB and others. It also provides an abstraction layer for map-reduce implementations like Hadoop.

Since 2010 there is a Spring Data Neo4j initiative. Some resources can be found on the Neo4j website. The best guidebook available at the moment is ‘Good Relationships’ written by Michael Hunger, the lead developer of this project. It is free for download and also available as HTML version. Some Spring Data Neo4j code examples are in the Spring Data Neo4j Git repository. There is also an O’Reilly book about Spring Data Neo4j.

Why not using core Neo4j?
Of course, it would also be possible to just use core Neo4j or build your own integration. But if you have experiences with other spring projects, you identify the benefits. As a software engineer in general, you do not want to care about technical details like the entity mapping or transaction management. You just have to know the concept and Spring handles the magic in the background. It is comparable to the Hibernate support in Spring:

  • Common Spring and Spring Data infrastructure. It is very easy to embed Neo4j in existing applications managed by the Spring framework.
  • Annotations to declare the nodes and their relationships.
  • Code much easier to comprehend.
  • Entity state is backed by graph database.
  • Support of Neo4j server.

How to use Spring Data Neo4j?
If you are using Maven you can include Spring Data Neo4j into your project by adding this to your pom.xml (beside the dependencies for Spring and Neo4j):

Read the Full Article Here.