I'm having trouble with the Graph API of OrientDB in Java.
Problem:
Retrieve Vertices (OrientVertex or Vertex?) from a persistent local graph database with several Vertices/Edges created via the console.
So for, I've been able to query the database from what I now think is the Document API using
graph = factory.getTx();
String string = String.format("select * from V where name like \"%s\"", criteria);
OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<OrientVertex>(string);
List<OrientDocument> results = graph.getRawGraph().command(query).execute();
But this will not work for Vertices. How do I run queries that return a list of Vertices in my database?
Thanks in advance.
You can avoid getting the rawGraph and executed command directly with orientGraph and returns an iterable of OrientVertex
like this :
graph = factory.getTx();
String query = String.format("select * from V where name like \"%s\"", criteria);
OSQLSynchQuery<OrientVertex> qr = new OSQLSynchQuery<OrientVertex>(query);
Iterable<OrientVertex> vertices = graph.command(qr).execute();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With