Search code examples
graphgraph-databasesorientdb

OrientDB Create Edge between a Vertex and ODocument


I have a database with a whole bunch of ODocument records. They have their own Class hierarchy and it does not extend V.

I am in the process of adding in new collections and to support some of the features - we would like to use the graph db capabilities.

So I created a new Vertex per
Vertex company = graph.addVertex(null);

I find my existing ODoc and convert that to a vertex as

Vertex person = null; for (Vertex v : graph.getVertices("Person.name", "Jay")) { person = v; }

and try to create an Edge

Edge sessionInIncident = graph.addEdge(null, company, person, "employs");

The edge creation leads to the following

Class 'Person' is not an instance of V
java.lang.IllegalArgumentException
at com.tinkerpop.blueprints.impls.orient.OrientElement.checkForClassInSchema(OrientElement.java:635)
at com.tinkerpop.blueprints.impls.orient.OrientVertex.addEdge(OrientVertex.java:905)
at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.addEdge(OrientBaseGraph.java:685)

Solution

  • In order to be a Vertex, class Person must extend the V class. Try this command:

    alter class Person superclass V