我需要更新顶点并将其作为ODocument
返回。
首先,我查询它,然后更新属性,最后将其作为ODocument返回。
但我只能检索Vertex
,而不是OrientVertex
:
Vertex vPlace = graph.getVertices("id",id).iterator().next();
我在http://orientdb.com/docs/2.2/Graph-Blueprints.html中找到了示例:
Iterable<OrientVertex> results = g.query().has("name", EQUALS, "fast");
但它没有编译:找不到“EQUALS”。
如何将顶点查询为OrientVertex
?
答案 0 :(得分:0)
这对你有用吗?
String dbName = "testDB";
OrientGraphFactory dbfactory = new OrientGraphFactory("remote:127.0.0.1:2424/"+dbName, "root", "root").setupPool(1, 50);
OrientGraph db = dbfactory.getTx();
try {
String query = "select from V where name = ?";
Iterable<OrientVertex> result = db.command(new OCommandSQL(query)).execute("testName");
while(result.iterator().hasNext()){
OrientVertex d = result.iterator().next();
//do something with d
System.out.println(d.getProperty("name"));
}
} catch (Exception e) {
// TODO: handle exception
System.out.println(e);
}