(1) I would suggest using OrientDB 2.1 and its documentation, for example. http://orientdb.com/docs/2.1/Tutorial-Record-ID.html
(2) From your post, itโs not clear to me if you need help getting the RID from the query results or retrieving an object based on its RID, so let me start by mentioning that the former can be executed as illustrated in this example (in the case of a query INSERT):
ODocument result=db.command(new OCommandSQL(<INSERTQUERY>)).execute(); System.out.println(result.field("@rid"));
Going the other way around, there are several approaches. I checked that the following works with version 2.1.8:
OrientGraph graph = new OrientGraph("plocal:PATH_TO_DB", "admin", "admin"); Vertex v = graph.getVertex("#16:0");
An alternative and more general approach is to build and execute a SELECT query of the SELECT FROM :RID form along the lines of this example:
List<ODocument> results = db.query(new OSQLSynchQuery<ODocument>("select from " + rid)); for (ODocument aDoc : results) { System.out.println(aDoc.field("name")); }
(3) In practice, it is usually better to use some other โdescriptorโ on the vertices and edges of OrientDB in Java code, or even when using any of the supported programming languages. For example, once one has a vertex like Java Vertex , as in the example above โVertex vโ, you can usually use it.
source share