I would expect Neo4jGraph.open(path)
to open an existing graph if present at that path or create a new one if it does not find one. I would not expect it to overwrite. I assume that you are not committing your transaction in your unit test prior to closing your graph:
gremlin> graph = Neo4jGraph.open('/tmp/neo4j')
==>neo4jgraph[community single [/tmp/neo4j]]
gremlin> g = graph.traversal()
==>graphtraversalsource[neo4jgraph[community single [/tmp/neo4j]], standard]
gremlin> g.addV('person').property('name','marko')
==>v[0]
gremlin> graph.close()
==>null
gremlin> graph = Neo4jGraph.open('/tmp/neo4j')
==>neo4jgraph[community single [/tmp/neo4j]]
gremlin> g = graph.traversal()
==>graphtraversalsource[neo4jgraph[community single [/tmp/neo4j]], standard]
gremlin> g.V()
gremlin> g.addV('person').property('name','marko')
==>v[0]
gremlin> g.tx().commit()
==>null
gremlin> graph.close()
==>null
gremlin> graph = Neo4jGraph.open('/tmp/neo4j')
==>neo4jgraph[community single [/tmp/neo4j]]
gremlin> g = graph.traversal()
==>graphtraversalsource[neo4jgraph[community single [/tmp/neo4j]], standard]
gremlin> g.V()
==>v[0]
As you can see, if I close()
without g.tx().commit()
and then re-open the graph the vertex I added is not present. However, with a call to commit()
I can re-open and get my vertex.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…