I am currently using GraphAware UUID Library to generate UUID in neo4j, later I found out that it has a randomUUID()
function to generate UUID, which one should be used?, will randomUUID()
create unique id on server?
They both call java.util.UUID#randomUUID()
, that's where the similarity between them ends.
The built-in Cypher's randomUUID()
is a function, which you have to call manually in each cypher query where you want to assign a UUID.
The neo4j-uuid
module is a set of extensions to Neo4j, which allow you to transparently assign UUID (or other types of ids - depending on configured id generator) to nodes and relationships, ensures the ids can't be changed or deleted. It also maintains an explicit index for the nodes / relationships. See the readme for the full feature set.
If your use case is simply to assign a uuid to (some) nodes or relationships then use the built in function. If you can take advantage of the other features of the neo4j-uuid module - use that.