OGraphDabatase.createVertex(className) doesn't work as expected #1387

ImpariTuriddu opened this Issue Mar 8, 2013 · 2 comments

3 participants


OrientDB version = 1.3.0
Tinkerpop version = 2.2.0
Configuration = the default one

Steps to reproduce the issue:
1. create the database and the subclass using the script at https://gist.github.com/ImpariTuriddu/5118062
2. run the test available at https://gist.github.com/ImpariTuriddu/5118153

As you can see, the documents created using OGraphDabatase.createVertex(className) are not stored as instance of the subclass but as instances of the superclass. This method worked fine in Orient 1.0.1 (I don't know in which version this stopped to work as expected). In order to actually create instances of the subclass you have to use OGraphDabatase.newInstance(className).

OrientDB member

Hi Salvatore,
I re-run the testcase in: com.orientechnologies.orient.graph.gremlin.BlueprintsTest and pass. Could you test it against latest snapshot? Dunno why doesn't work since nothing has changed since long time.

public class BlueprintsTest {
private static String DB_URL = "local:target/databases/tinkerpop";
private OrientGraph graph;

public BlueprintsTest() {

public void before() {
graph = new OrientGraph(DB_URL);

public void after() {

public void testSubVertex() {
if (graph.getRawGraph().getVertexType("SubVertex") == null)

Vertex v = graph.addVertex("class:SubVertex");
v.setProperty("key", "subtype");
Assert.assertEquals(((OrientVertex) v).getRawElement().getSchemaClass().getName(), "SubVertex");


public void testSubEdge() {
if (graph.getRawGraph().getEdgeType("SubEdge") == null)
if (graph.getRawGraph().getVertexType("SubVertex") == null)

Vertex v1 = graph.addVertex("class:SubVertex");
v1.setProperty("key", "subtype+subedge");
Assert.assertEquals(((OrientVertex) v1).getRawElement().getSchemaClass().getName(), "SubVertex");

Vertex v2 = graph.addVertex("class:SubVertex");
v2.setProperty("key", "subtype+subedge");
Assert.assertEquals(((OrientVertex) v2).getRawElement().getSchemaClass().getName(), "SubVertex");

Edge e = graph.addEdge("class:SubEdge", v1, v2, null);
e.setProperty("key", "subedge");
Assert.assertEquals(((OrientEdge) e).getRawElement().getSchemaClass().getName(), "SubEdge");



I just ran into this issue and it appears that multi-threads access to the database is the culprit. OrientBaseGraph.openOrCreate(..) calls setUseCustomTypes(false) so you'll need to make sure that you that your database thread instance has it's use custom types set to true before any add operation.

@lvca lvca closed this Oct 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment