unremarkable
unremarkable

Reputation: 260

Recreate reference node in a Neo4j database

I accidentally deleted node 0, which was my reference node on a new graph, so calls to getReferenceNode() would fail afterwards. I searched through the Neo4j source and found a that I could recreate it using:

GraphDatabaseService graphDb = new EmbeddedGraphDatabase("mytestdb");    
((EmbeddedGraphDatabase) graphDb).getConfig().getGraphDbModule().createNewReferenceNode();

Am I missing a better way to recreate the reference node? Sometimes it gets an id of 0, sometimes 5 when I run this, depending on what other nodes exist. Also, comments around getConfig() say that it may be removed in future releases.

Upvotes: 4

Views: 1882

Answers (1)

Kristian Glass
Kristian Glass

Reputation: 38530

Some time has passed since you asked this, but for your information there was some semi-recent discussion about reference nodes in a Neo4j GitHub issue - in summary, Peter Neubauer (Neo Technology employee) discusses either removing the concept of reference nodes, or adding a setReferenceNode() API call.

There doesn't seem much conclusion from that thread, but to answer your question literally, right now you're not missing a better way to recreate the reference node - hopefully one will be coming soon!

Upvotes: 3

Related Questions