0

How can I load the vertices of a specific type using the Tinkerpop 3 Java API. With Tinkerpop 2.x it was possible to use the "@class" property. This does not seem to work with TP 3.x.

@Test
public void testOrientDB() {

    try (OrientGraphFactory graph = new OrientGraphFactory()) {
        graph.setupPool(10, 100);

        try (OrientGraph tx = graph.getTx()) {
            for (int e = 0; e < 10_000; e++) {
                Vertex v = tx.addVertex("Person");
                v.property("name", "blab" + e);
                Vertex v2 = tx.addVertex("Job");
                v2.property("name", "blub" + e);
            }
            tx.commit();
        }

        try (OrientGraph tx = graph.getTx()) {
            System.out.println("Persons: " + tx.traversal().V().has("@class", "Person").count().next());
        }
    }
}
Jotschi
  • 3,270
  • 3
  • 31
  • 52

1 Answers1

0

It is possible to use the hasLabel step to find the elements:

tx.traversal().V().hasLabel("Person").count().next()

Jotschi
  • 3,270
  • 3
  • 31
  • 52