Spring Projects

Spring Data Neo4j

Spring Data Neo4j enables POJO based development for the Graph Database Neo4j. It maps annotated entity classes to the Neo4j Graph Database with advanced mapping functionality. The template programming model is equivalent to well known Spring templates and builds the basis for interaction with the graph and is also used for the advanced repository support.
Spring Data Neo4j is part of the Spring Data project which aims to provide convenient support for NoSQL databases.

Spring Data Neo4j enables POJO based development for the Graph Database Neo4j. It maps annotated entity classes to the Neo4j Graph Database with advanced mapping functionality. The template programming model is equivalent to well known Spring templates and builds the basis for interaction with the graph and is also used for the advanced repository support.
Spring Data Neo4j is part of the Spring Data project which aims to provide convenient support for NoSQL databases.

#maven
Spring Data Neo4j logo

"I’m excited about Spring Data Neo4j ... Spring Data Neo4j makes working with Neo4j amazingly easy, and therefore has the potential to make you more successful as a developer. ... I encourage you to explore Spring Data, and — better still — become involved in the community and contribute."

Rod Johnson, Founder, Spring and SVP, Application Platform, VMware

Spring Data Neo4j is released under the Apache Software License. Its source code is hosted on github. Several examples can also be found there. A set of developer notes as quick-lookup reference card provides essential information.
Issue tracker and discussion forums are provided at springsource.org. You can follow @SpringData and @Neo4j on twitter and also subscribe to the Neo4j discussion group for more information.

Neo4j Logo

Latest News

Webinars

Here is an overview of Spring Data Neo4j features

  • Support for property graphs (nodes connected via relationships, each with arbitrary properties)
  • Object-Graph-Mapping of annotated POJO entities
  • additional advanced mapping mode via AspectJ
  • Neo4jTemplate with convenient API, exception translation and optional transaction management
  • extensive Spring Data Commons Repositories Support, including annotated, derived and geospatial finder methods
  • Dynamic type projections (duck typing)
  • Supports the Cypher and Gremlin query languages
  • Different type representation strategies for keeping type information in the graph
  • Cross-store support for partial JPA - Graph Entities
  • Neo4j Traversal support on dynamic fields and via repository methods
  • Neo4j Indexing support (including unique entities, full-text, spatial and numeric range queries)
  • Support for transparently accessing the Neo4j Server via its REST API
  • Support for running as extensions in the Neo4j Server

Getting Started

For a quick introduction please have a look at the five minute introduction and check out the examples. For a more comprehensive tutorial enjoy our Spring Data Neo4j Guide Book "Good Relationships" and glance at our Developer Notes.
Here is just a quick teaser.

Example

 @NodeEntity
 public class Movie {

    @GraphId Long id;

    @Indexed(type = FULLTEXT, indexName = "search")
    String title;

    Person director;

    @RelatedTo(type="ACTS_IN", direction = INCOMING)
    Set<Person> actors;

    @RelatedToVia(type = "RATED")
    Iterable<Rating> ratings;

    @Query("start movie=node({self}) match
            movie-->genre<--similar return similar")
    Iterable<Movie> similarMovies;
 }

Repositories

 interface MovieRepository extends GraphRepository<Movie> {
  @Query("start movie={0} match m<-[rating:RATED]-user
        return rating")
  Iterable<Rating> getRatings(Movie movie);
  // Co-Actors
  Iterable<Person> findByActorsMoviesActorName(name)
 }

 <neo4j:repositories base-package="com.example.dao"/>
 
    
 @Autowired MovieRepository repo;
    
 Iterable<Movie> movies = repo.findAll();
 Movie movie = repo.findByPropertyValue("title","Matrix");
 repo.save(movie);
 
 Iterable<Rating> ratings = repo.getRatings(movie);

Social movie database tutorial - cineasts.net

The Social Movie Database Webapp uses the Spring Framework, Spring Data Neo4j and Neo4j based on data from themoviedb.org.
The application is documented in the Spring Data Neo4j Guide Book, and its source code available on GitHub as part of the Spring Data Neo4j examples.

Spring Data Neo4j Guide Book - "Good Relationships"

Despite being just a library Spring Data Neo4j comes with a real Guide Book, featuring:

Blogs

Maven Artifacts

Stable Release

    <dependency>
 <groupId>org.springframework.data</groupId>
 <artifactId>spring-data-neo4j</artifactId>
 <version>2.2.0.RELEASE</version>
</dependency>

 

Milestone Release

<repository>
 <id>spring-snapshot</id>
 <name>Spring Maven SNAPSHOT Repository</name>
 <url>http://repo.springsource.org/libs-milestone</url>
</repository>

<dependency>
 <groupId>org.springframework.data</groupId>
 <artifactId>spring-data-neo4j</artifactId>
 <version>2.2.0.RELEASE</version>
</dependency>

 

Snapshot Release

<repository>
 <id>spring-snapshot</id>
 <name>Spring Maven SNAPSHOT Repository</name>
 <url>http://repo.springsource.org/libs-snapshot</url>
</repository>

<dependency>
 <groupId>org.springframework.data</groupId>
 <artifactId>spring-data-neo4j</artifactId>
 <version>2.3.0.BUILD-SNAPSHOT</version>
</dependency>

 

Current Stable Release (2.2.0.RELEASE)

Nightly Builds (2.3.0.BUILD-SNAPSHOT)

 

 


Quick Jump

Download
Maven Artifacts
Documentation
Discussions

Source Repository
Examples Repository

 


Documentation

Current Stable Release (2.2.0.RELEASE)

Nightly Builds (2.3.0.BUILD-SNAPSHOT)

 


Other Resources

 


Related Discussions

NoSQL