3
我我的集成系統Neo4j的,這將是對我有意思創建使用Cypher支架查詢語言的節點,因此,作爲測試嵌入式Neo4j的應用程序創建節點,我想做這樣的事情:與Cypher支架
String path = "test.graphdb";
AbstractDatabase db = new Neo4jDatabase(path, true, false);
db.makeQuery("CREATE (n:Dog {name:'Sofia'})");
db.makeQuery("CREATE (n:Dog {name:'Laika'})"); db.makeQuery("CREATE (n:Dog {name:'Gaia'})");
Result result = db.makeQuery("MATCH (n:Dog) RETURN n");
boolean hasNext = result.hasNext();
System.out.println(hasNext);
凡Neo4jDatabase類裏面我有一個是這樣這樣makeQuery方法:
public Result makeQuery(String string)
{
try(Transaction ignored = this.db.beginTx();
Result result = this.db.execute(string))
{
return result;
}
}
不幸的是,它返回false,一如果節點還沒有創建!哪裏不對?
是的,另一個有意思的地方是,訪問result.next()也是你在事務內部必須做的事情! –