Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
ImpariTuriddu opened this Issue · 2 comments

3 participants

Salvatore Piccione Luca Garulli Sharmarke Aden
Salvatore Piccione

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).

Luca Garulli
Owner

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() {
}

@BeforeClass
public void before() {
graph = new OrientGraph(DB_URL);
graph.getRawGraph().setUseCustomTypes(true);
}

@AfterClass
public void after() {
graph.shutdown();
}

@Test
public void testSubVertex() {
if (graph.getRawGraph().getVertexType("SubVertex") == null)
graph.getRawGraph().createVertexType("SubVertex");

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

}

@Test
public void testSubEdge() {
if (graph.getRawGraph().getEdgeType("SubEdge") == null)
graph.getRawGraph().createEdgeType("SubEdge");
if (graph.getRawGraph().getVertexType("SubVertex") == null)
graph.getRawGraph().createVertexType("SubVertex");

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");

}
}

Sharmarke Aden

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.

Luca Garulli lvca closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.