Search code examples
graph-databasesorientdbfactory-patternorientdb2.2orientdb-2.1

OrientDB migration from 2.0.12 to 2.2.18


I was using below API for fetching the vertex in 2.0.12 and it was working

OrientGraphFactory factory = new OrientGraphFactory("remote:172.21.112.228/mydb", "root", "root").setupPool(1,50);
        OrientGraphNoTx graph = factory.getNoTx();
graph.getVertices("Test.name","zyx");

But with the latest 2.2.18, when I tried with

OrientGraphFactory factory = new OrientGraphFactory("memory:172.21.112.228/mydb", "root", "root").setupPool(1,50);
        OrientGraphNoTx graph = factory.getNoTx();
graph.getVertices("Test.name","zyx");

I am getting below error,

Exception in thread "main" java.lang.IllegalArgumentException: 
OClass not found in the schema: Test
    at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.getVertices(OrientBaseGraph.java:814)
    at test.GetOrientDBData.main(GetOrientDBData.java:57)

Solution

  • Try following code:

    OrientGraphFactory factory = new OrientGraphFactory("memory:mydb", 
         "root", "root").setupPool(1,50); 
    OrientGraphNoTx graph = factory.getNoTx(); 
    if(g.getVertexType("Test") == null){
      g.createVertexType("Test");
    }
    graph.getVertices("Test.name","zyx");
    

    Two changes on your code:

    1. removed the IP in the memory: URL, no need for that

    2. added a check to make sure that Test class exists and in case create it