Skip to content

Instantly share code, notes, and snippets.

@fabriziofortino
Last active August 29, 2015 13:56
Show Gist options
  • Save fabriziofortino/8864348 to your computer and use it in GitHub Desktop.
Save fabriziofortino/8864348 to your computer and use it in GitHub Desktop.
OSQLAsynchQuery does not return edges
import com.orientechnologies.orient.core.command.OCommandResultListener;
import com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.impls.orient.OrientVertex;
public class OrientdbTest {
public static void main(String[] args) {
final OrientGraph graph = new OrientGraph(
"remote:localhost/GratefulDeadConcerts", "admin", "admin");
OrientVertex v1 = graph.addVertex(null);
v1.setProperty("name", "xxx");
OrientVertex v1_1 = graph.addVertex(null);
OrientVertex v1_2 = graph.addVertex(null);
graph.addEdge(null, v1, v1_1, "has");
graph.addEdge(null, v1, v1_2, "has");
graph.commit();
// the following code does not print any edge ...
graph.command(
new OSQLAsynchQuery<Vertex>("select from " + v1.getId(),
new OCommandResultListener() {
public boolean result(Object iRecord) {
Vertex doc = graph.getVertex(iRecord);
System.out.println("V " + doc);
for (Edge e : doc.getEdges(Direction.BOTH)) {
System.out.println("E " + e);
}
return true;
}
public void end() {
// TODO Auto-generated method stub
}
})).execute();
// .. in sync mode it works
Iterable<Vertex> vIter = graph.command(
new OSQLSynchQuery<Vertex>("select from " + v1.getId()))
.execute();
for (Vertex v : vIter) {
for (Edge e : v.getEdges(Direction.BOTH)) {
System.out.println("E " + e);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment