So I tried to run the following cypher query with the ExecutionEngine:
MATCH (n:Person{name:'Test'}) MATCH n-[r]->m RETURN n,r,m;
>
And then I wanted to get n, r and m out of it like this:
Node node = IteratorUtil.single(result.javaColumnAs("n"));
> Relationship relationship = IteratorUtil.single(result.javaColumnAs("r"));
> Node otherNode = IteratorUtil.single(result.javaColumnAs("m"));
Now this does not work. Only the first javaColumnAs returns the node,
everything after does not return anything anymore.
I found the reason here:
https://groups.google.com/d/msg/neo4j/oUP_2b8mAlY/hkgJGoHc-20J
Explanation: After doing javaColumnAs once, it consumes all the results
from the cypher query because it is a lazy iterator.
Another way to get all of them out is:
> Node node = null;
> Relationship relationship = null;
> Node otherNode = null;
>
> for (Map<String, Object> row :
> IteratorUtil.asIterable(result.javaIterator())) {
> for (Map.Entry<String, Object> column : row.entrySet()) {
>
> switch (column.getKey()){
> case "n":
> node = (Node) column.getValue();
> break;
> case "r":
> relationship = (Relationship) column.getValue();
> break;
> case "m":
> otherNode = (Node) column.getValue();
> break;
> }
> }
> }
You might agree, that this does not look as sexy as the first version. But
HOW can I make this nicer? I would love it to look kind of like the first
code example. But that one does not work. Is there a solution similar to
that one that does work as expected?
Thank you very much for your help.
Cheers,
Patrick
--
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.