...在顶点和Neo4j - ReferenceNode之间创建边/关系时总是会遇到异常。
如何处理这样的事情?
GraphDatabaseService neoGraphDbService = new EmbeddedGraphDatabase( "d:/testDb" );
System.out.println(neoGraphDbService.getReferenceNode()); // Node[0]
Graph tiGraphDb = new Neo4jGraph(neoGraphDbService);
Vertex referenceNode = tiGraphDb.getVertex(0);
//throws Exception:
//org.neo4j.graphdb.NotFoundException: Node[0]
System.out.println(neoGraphDbService.getReferenceNode());
//referenceNode is null
System.out.println(referenceNode);
Vertex a = tiGraphDb.addVertex(null);
Vertex b = tiGraphDb.addVertex(null);
a.setProperty("name","marko");
b.setProperty("name","peter");
Edge referenceNode_knows_a = tiGraphDb.addEdge(null, referenceNode, a, "knows");
Edge a_knows_b = tiGraphDb.addEdge(null, a, b, "knows");
tiGraphDb.shutdown();
这是我对tinkerpop的第一次体验,我不明白referenceNode究竟发生了什么,一旦我做了tinkerpop连接,它似乎就迷失了......
顺便说一句。还没有用于tinkerpop,蓝图等的标签......
答案 0 :(得分:0)
如果您未指定图表不是新鲜的,蓝图将删除参考节点。尝试
Graph tiGraphDb = new Neo4jGraph(neoGraphDbService, false);
防止蓝图插入图表。
/ peter