Hi Herman! The examples are updated and work in the version of Neo4j they are intended for. Actually, the code is executed in every build.
In this case, the full source for the example snippets is found here: https://github.com/neo4j/neo4j/blob/2.0.1/community/cypher/cypher-docs/src/test/java/org/neo4j/cypher/javacompat/JavaQuery.java I do see one problem with this class: it sits in the same package as ExecutionResult and ExecutionEngine, so it doesn't import them. I'll make sure these lines are added to the example code: import org.neo4j.cypher.javacompat.ExecutionEngine; import org.neo4j.cypher.javacompat.ExecutionResult; I don't know what's going on in Eclipse, couldn't reproduce. /anders On Thu, Apr 10, 2014 at 10:42 AM, Herman Torjussen < [email protected]> wrote: > I've tried several examples from > http://docs.neo4j.org/chunked/2.0.1/tutorials-cypher-java.html but none > are compatible with the API I'm using it seems. > > I'm using 2.0.1 API with Maven: > > <dependency> > <groupId>org.neo4j</groupId> > <artifactId>neo4j</artifactId> > <version>2.0.1</version> > </dependency> > <dependency> > <groupId>org.neo4j</groupId> > <artifactId>neo4j-kernel</artifactId> > <version>2.0.1</version> > <type>test-jar</type> > </dependency> > > > > Consider this example: > > try (Transaction tx = db.beginTx()) { > result = engine.execute(String.format("MATCH (x:%s) RETURN x", label > )); > for ( Map<String, Object> row : result) { > for ( Entry<String, Object> column : row.entrySet()) { > rows += column.getKey() + ": " + column.getValue() + "; "; > } > rows += "\n"; > } > } > > > My Eclipse tells me this about the "result" variable: "Can only iterate > over an array or an instance of java.lang.Iterable". > Also, when trying another example, I'm getting "Type mismatch: cannot > convert from Iterator<Object> to Iterator<Node>" for the "result" variable. > > > try (Transaction tx = db.beginTx()) { > result = engine.execute(String.format("MATCH (x:%s) RETURN x", label > )); > Iterator<Node> n_column = result.columnAs( "n" ); > for ( Node node : IteratorUtil.asIterable( n_column ) ) { > // note: we're grabbing the name property from the node, > // not from the n.name in this case. > nodeResult = node + ": " + node.getProperty( "name" ); > } > } > > > Are these examples updated? What am I missing here? I just want get a List > of nodes having a particular label.. > > -- > You received this message because you are subscribed to the Google Groups > "Neo4j" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- Anders Nawroth [[email protected]] Skype: anders.nawroth -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
