如何通过OrientDB java api获取标签/类的边缘

时间:2016-10-02 23:48:29

标签: java orientdb

我希望在java api上使用一个或多个类/标签从一个顶点开始出边。

这是我的示例代码,它会导致NPE。 我尝试使用Edge和OrientEdge。

private Iterable<OrientEdge> queryNextEdges(OrientVertex vertex) {
    OrientGraphFactory factory = new OrientGraphFactory(
            "remote:127.0.0.1:2424/xyz", "admin", "admin"
    ).setupPool(1, 10);
    OrientGraph graph = factory.getTx();
    Iterable<OrientEdge> queryResult;
    try {
        queryResult = (Iterable<OrientEdge>) (OrientEdge) vertex.getEdges(Direction.OUT, "hierarchy");
    } finally {
        graph.shutdown();
    }
    return queryResult;
}

错误:

Caused by: java.lang.NullPointerException
at com.tinkerpop.blueprints.impls.orient.OrientVertex.getFieldNames(OrientVertex.java:1042)
at com.tinkerpop.blueprints.impls.orient.OrientVertex.getEdges(OrientVertex.java:810)
at com.tinkerpop.blueprints.impls.orient.OrientVertex.getEdges(OrientVertex.java:782)
at ebs.window.graphLayout.GraphLayoutPresenter.queryNextEdges(GraphLayoutPresenter.java:214)

1 个答案:

答案 0 :(得分:2)

我尝试重现你的例子并且它有效。

enter image description here

希望它有所帮助。