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:
https://dzone.com/articles/assigning-uuids-neo4j-nodes
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: https://github.com/spring-projects/spring-data-neo4j/blob/master/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/web/domain/User.java 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: https://docs.spring.io/spring-data/neo4j/docs/current/reference/html/ They seem to using UUID's as their example for a usecase of an AddUuidPreSaveEventListener
Questions
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;
...
@Convert(UuidStringConverter.class)
@Index(unique = true, primary = true)
private UUID uuid = UUID.randomUUID();
...
to my GraphType.java 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.