Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving OrientVertex Objects from OrientDB

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.

like image 968
Ethan Hohensee Avatar asked Feb 11 '23 10:02

Ethan Hohensee


1 Answers

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();
like image 128
wolf4ood Avatar answered Feb 16 '23 17:02

wolf4ood