Quote of the Day

more Quotes

Categories

Get notified of new posts

Buy me coffee

Backend API with Spring Boot, Spring Data and Neo4j.

Published April 12, 2018 in Neo4j , Spring Framework - 0 Comments

Spring Boot has made it simpler than ever to get setup with Neo4j. Pretty much the only dependency you need to get started is the spring-boot-starter-data-neo4j, which includes a number of other Spring dependencies for all Spring magics, and neo4j ogm dependencies.

Three key players involve in the configurations for connecting to neo4j and doing data access operations utilizing Spring: Transaction Manager, SessionFactory and Configuration.

Configuration – Allows you to either supply a path to a configuration file or programmatically set the configurations. For the different configuration settings, refer to the manual .

For integration tests, if you don’t provide a URL to the graph database. The neo4j-ogm will automatically configures an embedded, ephemeral neo4j database.

/**
 * Configuration for embedded database.
 * @return
 */
@Bean
public Configuration configuration()
{
    Configuration configuration = new Configuration.Builder(  ).build();
    return configuration;
}

Neo4j OGM SessionFactory – Uses for creating sessions. You only need one instance of SessionFactory for your application.

A session provides an interface for interactions with a graph database. It exposes methods to perform arbitrary cypher queries. The session also has metadata to track changes such that it is able to persist only the changes and not the entire subgraph. For more information, check out the neo4j documentation on session.

Neo4jTransactionManager – This is spring transaction manager for neo4j.

Checkout my sample project as an example for getting started.

No comments yet