New Release: Spring Data Neo4j 4.1 Milestone 1

Learn about the New Milestone 1 Release of Spring Data Neo4j 4.1 and the Neo4j-OGMAs part of the first milestone of the Spring Data release Hopper Train, Spring Data Neo4j 4.1 Milestone 1 was made available last week. We also published the second milestone release for the Neo4j Object Graph Mapper (Neo4j-OGM) 2.0. I’m really happy to see how it all comes together now.

Many of the improvements in Spring Data Neo4j 4.1 built on the recently announced Neo4j-OGM 2.0 updates.

New Features in Spring Data Neo4j 4.1-M01

Most notably the support for different protocol drivers now allows you to use Neo4j embedded again as an alternative to communicating via HTTP with the Neo4j server. That capability also comes in handy for unit testing. By the final release of the OGM and Spring Data Neo4j (SDN), we will also support the new binary Bolt protocol for Neo4j 3.0.

Another long-awaited feature is the full support of rich relationship entities that allow you to map relationships to annotated entity types and create, load and save them as first-class citizens.

The other big improvements happened under the hood with a rewrite of the Cypher statement generator, which is responsible for turning your CRUD operations on entities into efficient Cypher statements. The current change let to one to two orders of magnitude improvements in performance and memory usage, especially when updating larger graph structures.

Complex Cypher queries that are executed via annotated repository methods can now map their full results (including entities) into DTO classes that are annotated with @QueryResult. As you should not rely on pulling large parts of the graph database into application memory to then just use a few fields of some entities, using well-tailored Cypher statements to extract exactly the information you need – and no more – is the way to go. We’re happy to support this approach now better with more complete result mappings.

A Result Mapping Example

public interface MovieRepository extends GraphRepository {

    @Query("MATCH (movie:Movie)-[r:RATING]->(), (movie)<-[:ACTS_IN]-(actor:Actor) " +
           "WHERE{movieId} " +
           "RETURN movie as movie, COLLECT(actor) AS cast, AVG(r.stars) AS averageRating")
    MovieData getMovieData(@Param("movieId") String movieId);

    public class MovieData {
        Movie movie;
        Double averageRating;
        Set cast;


You can provide the configuration for choosing a certain driver via an file in your classpath or as part of your Spring configuration as a bean. More details can be found in the driver configuration documentation. for HTTP Driver

URI=https://neo4j:password@localhost:7474 for Embedded Driver

# leave off to use impermanent-graphdb for testing

Driver Configuration as Spring Bean

public Configuration getConfiguration() {
   Configuration config = new Configuration();
   return config;

With these changes, we are also eager to try (again) to get Spring Data Neo4j 4.1 into the upcoming Spring Boot release which got stuck last time on licensing and dependency issues. Besides the noted changes, a lot of other issues were fixed as well; please refer to the changelogs (Spring Data Neo4j, Neo4j-OGM) for details.

As the next release of the Hopper Release train will already be a Release Candidate we would like to ask you for your help in testing these changes, especially the embedded driver, rich relationships, performance and result mapping and provide your feedback.

Please submit feedback via the #neo4j-sdn channel in our public Discord, at Spring Data Neo4j JIRA issues or by dropping us a quick email to

Special thanks to the team from GraphAware, especially Luane Misquitta and Vince Bickers for all the hard work and the swift response to feedback.

Yours truly,

Michael for the Spring Data Neo4j team