Learn All about the Official General Availability Release of Spring Data Neo4j 4.0After a full year of hard work, we are very happy to announce the general availability of Spring Data Neo4j 4.0.

Many thanks goes out to the great team from our partner GraphAware (Vince, Adam, Luanne, Michal), and the dedicated support of Pivotal’s Spring Data project lead Oliver Gierke, who worked with us to make this release a reality.

Because of their efforts (and those of many others), the first officially supported* version of Spring Data Neo4j is finally here.

(*For our customers with an Enterprise subscription, of course!)

History


In 2009, Rod Johnson (founder of SpringSource) and Emil Eifrem jointly started Spring Data Neo4j as a personal project which became the incubating project of Pivotal’s Spring Data efforts.

Versions 1 through 3 did a good job supporting users who wanted to use Neo4j embedded in the Spring Framework for both enterprise and personal projects. These versions used Neo4j in-process via its embedded Java APIs.

But we also want future Spring Data Neo4j users to have a great experience working with Neo4j in regular (non-embedded) mode, which today is the dominant way of accessing Neo4j. This was a best-effort in previous versions of SDN, as the embedded version had the luxury of making lots of back-and-forth calls in a way that’s simply too expensive when you’re accessing a database over the wire.

Also, since Neo4j is very focused on the Cypher query language as the most convenient way of interacting with Neo4j, we wanted to provide an object-graph-mapping library that makes extensive use of Cypher as its API.

Given those requirements, we began work on a new version of Spring Data Neo4j in fall 2014, learning from the past and targeting future use cases and developments.

The result: Spring Data Neo4j 4.0 was to be a rewrite from the ground up.

This time we decided to build a plain Java-Object-Graph-Mapper first, which can be used independently of Spring (e.g., in J2SE, Android, J2EE environments and for other JVM languages). The Spring Data integration then happens on top of this base library, neo4j-ogm.

We also wanted to make it easier to evolve the transport layer (to be prepared for the forthcoming Neo4j binary transport). Now the Spring Data Neo4j client-server protocol is pluggable: it uses Neo4j’s existing HTTP APIs and in the future will be able to switch to a binary RPC protocol.

Get Started


It’s easy to get started by cloning one of the provided example project repositories on GitHub as starting point. The basic concepts are very similar to all the other Spring Data projects and Object-Database-Mappers in general.

The “Cineasts” movie database project is an especially well-documented tutorial for Spring Data Neo4j 4.

In addition, Luanne Misquitta wrote an excellent introductory article on The Essence of Spring Data Neo4j 4.

Setup


We also prepared for the next version of Spring Boot to provide Spring Data Neo4j support, which automagically enables as soon as you have the project dependencies available.

Until then, get started with Spring Data Neo4j by adding the dependency to your build configuration: org.springframework.data:spring-data-neo4j:4.0.0.RELEASE.

Then provide your basic configuration class:

@Configuration
@EnableNeo4jRepositories("org.neo4j.cineasts.repository")
public class PersistenceContext extends Neo4jConfiguration {

    @Autowired Environment env;

    @Bean
    public SessionFactory getSessionFactory() {
        return new SessionFactory("org.neo4j.cineasts.domain");
    }

    @Bean
    public Neo4jServer neo4jServer() {
        return new RemoteServer(env.getProperty("neo4j.url"));
    }
}

And you can start mapping your (even unannotated) entities to the graph. With additional annotations – as shown below – you have more control over the mapping.

@NodeEntity
public class Movie {

  @GraphId Long id;

  String title;

  Person director;

  @Relationship(type="ACTED_IN", direction = "INCOMING")
  Set actors = new HashSet<>();
}

Support for the beloved Spring Data Repositories is provided as well.

interface MovieRepository extends GraphRepository {

  @Query("MATCH (m:Movie)<-[rating:RATED]-(user)
             WHERE id(m) = {movieId} RETURN rating")
  Iterable getRatings(Long movieId);

  Collection findByTitle(name);
}

Please note that for existing Spring Data Neo4j 3.x users, while we did our best to minimize the overhead of upgrading, some migration effort is necessary as configuration and annotations have changed in the new version.

With this release we also are making available the Neo4j-OGM library in version 1.1.2, which Spring Data Neo4j is built upon.

You can find more information about the project on our developer pages.

Resources




Need to sharpen your skills with Neo4j before diving into SDN4? Download your free copy of the Learning Neo4j ebook and catch up to speed with the world’s leading graph database.

Get My Free Copy

 

Keywords:  


About the Author

Michael Hunger, Developer Relations

Michael Hunger Image

Michael Hunger has been passionate about software development for a very long time. For the last few years he has been working on the open source Neo4j graph database filling many roles.

As caretaker of the Neo4j community and ecosystem he especially loves to work with graph-related projects, users and contributors. As a developer, Michael enjoys many aspects of programming languages, learning new things every day, participating in exciting and ambitious open source projects and contributing and writing software related books and articles.


1 Comment

Hans Desmet says:

It was a pleasure to use Spring Data Neo4j 4.0 in a NoSQL training I gave to colleagues !

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe

Upcoming Event

 

From the CEO

Emil's Blog


Have a Graph Question?

Stackoverflow
Slack
Contact Us

Share your Graph Story?

Email us: content@neotechnology.com


Popular Graph Topics