user2524707 user2524707 - 6 months ago 52
Java Question

OrientDB difference between vertex label and vertex class

I just started using orientDB and I'm confused whether I have to use label or class.

public Iterable<com.tinkerpop.blueprints.Vertex> getVertices(String label,
String[] iKey,
Object[] iValue)

Uses label, but I couldn't find what that label stands for.
If I want to have it from a specific category "Animal" "Company" etc do I have to get and store it as a class?


If you want to retrive all the vertices from a class you can use this:

Iterable<Vertex> result2=g.getVerticesOfClass("Person");
            for(Vertex v:result2){  
                String rid=v.getId().toString();
                String name=v.getProperty("name");
                String surname=v.getProperty("surname");
                System.out.println(rid + " " + name + " " + surname);  


If you want to use the command posted above you have to do something like this:

        String [] properties = {"name"};
        String [] value = {"pluto"};

        Iterable<Vertex> i_ad = g.getVertices("Animal", properties, value);
        for(Vertex v:i_ad){ 

label stands for the name of the class.

And there's no other way to avoid the iteration.

Hope it helps.