java - Creating Node in Embedded Neo4J Application with Cypher -


i'm integrating system neo4j , interesting me create nodes using cypher query language, therefore, test, i'm trying this:

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); 

where inside neo4jdatabase class have makequery method goes this:

public result makequery(string string) {     try(transaction ignored = this.db.begintx();         result result = this.db.execute(string) )     {         return result;     }  } 

unfortunately, returns false, if nodes had not been created! wrong?

you yourself, ignore transaction :)

you should call tx.success() in transaction block, after iterated on result.

don't hand out result when closed transaction, data in not accessible outside of tx.

for these simple statements can leave tx-handling cypher, no need start manual transactions.

but have iterate on or result.close() results finish cypher operation.


Comments