Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-02-2020 05:51 AM
Hello!
I'm trying to create UserFunction that executes CYPHER query and returns Node object.
Result result = db.execute(str_qry.toString())
How can i get org.neo4j.graphdb.Node from org.neo4j.graphdb.Result ?
Thank you!
10-03-2020 05:06 PM
what you need is to return a stream of a wrapping class for example
public Stream<MapResult> ..... {
Result result = db.execute(str_qry.toString())
return result .stream().map(NodeResult ::new)
}
and a NodeResult Class
import org.neo4j.graphdb.Node;
public class NodeResult {
public final Node node;
public NodeResult(Node node){this.node=node;}
@Override
public boolean equals (Object o){
return this == o || o!=null && getClass()==o.getClass() && node.equals(((NodeResult)o).node);
}
@Override
public int hashCode(){return node.hashCode();}
}
as a side note read this blog for tons and tons on info regarding procedures
10-11-2020 05:18 AM
reason: Incompatible types: Map<String, Object> is not convertible to Node
10-15-2020 10:30 AM
if you'd like to share more of your code i'd be happy to help. Please note that you must return a stream of value and types listed in the docs here.
All the sessions of the conference are now available online