如何将顶点查询为 OrientVertex

How to query vertex as OrientVertex

我需要更新顶点并将其 return 设为 ODocument。 首先,我查询它,然后更新属性,最后 return 它作为 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?

这对你有用吗?

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);
}