Hot questions for Using Neo4j in spring mvc

Top Java Programmings / Neo4j / spring mvc


Background I am trying to figure out the correct way to add a UUID to neo4j if I am using Spring Data.

I have seen: and here a TransactionEventHandler is used to insert a UUID when necessary. But the person who made this tutorial was not using spring data.

I have also seen this person's code: They seem to be using java's java.util.UUID and then just converting it to a string and using it as a string entity and indexing it and going from there. This seems to be the simplest way.

But, in the docs: They seem to using UUID's as their example for a usecase of an AddUuidPreSaveEventListener


Which method should I use for adding UUID's?

Could I just add

import java.util.UUID;

import org.neo4j.ogm.annotation.Index;
import org.neo4j.ogm.annotation.typeconversion.Convert;
import org.neo4j.ogm.typeconversion.UuidStringConverter;


@Index(unique = true, primary = true)
private UUID uuid = UUID.randomUUID();


to my file and call it good?

Note: I am very new to all these technologies and could be still too inexperienced to even properly ask a question on this stuff.

Note 2: I have seen the graphaware UUID library before, it does seem to be fairly up to date, but I assumed that there may be a preferred way to make UUIDs if I was working with spring data.


You can use the GraphAware Neo4j UUID library.

The docs says:

GraphAware UUID is a simple library that transparently assigns a UUID to newly created nodes and relationships in the graph and makes sure nobody can (accidentally or intentionally) change or delete them.

Simply download GraphAware Neo4j Framework and GraphAware Neo4j UUID .jar files to /plugins directory, modify few lines in neo4j.conf file and restart Neo4j. After it, UUIDs will be assigned to each node / relationships created in the Neo4j graph.

This approach does not depends on Spring or Spring Data.


I am using spring boot application mvc with graphDb (Neo4j) as my database. And I have problem when I have to do internationalization for my app. I have this code on my

public class Application extends Neo4jConfiguration {

    GraphDatabase graphDatabase;

    GraphDatabaseService graphDatabaseService() {
        return new GraphDatabaseFactory().newEmbeddedDatabase("my-graphdb");

    public static void main(String[] args) {, args);

When I tried to implement internationalization, the tutor says that I need to implement:

public void addInterceptors(InterceptorRegistry registry) {

This code above need the class is extended by WebMvcConfigurerAdapter. This is the problem, I didn't use WebMvcConfigurerAdapter so I cannot add the method above. Do I have another option to make my internationalization work well with Neo4jConfiguration?


I just found out how to make it work. I just have to add new file that extend WebMvcConfigurerAdapter and put the addInterceptors module into that new file.


Trying to run the neo4j spring data example on



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;

but the @Indexed(type = FULLTEXT, indexName = "search") does not seem to exist in <artifactId>spring-data-neo4j</artifactId> Do I have to add anything else to the pom ? or is this deprecated and if so how should I do it?


@Indexed was present in SDN 3, but not anymore in SDN 4. You have to manage indices and constraints yourself, using Cypher queries.

Shameless plug: you can use Liquigraph to manage your migrations.