I'm testing Tinkerpop frames. I have a relationship similar to Person Knows Person but everytime I test my code it gives me this error
com.orientechnologies.orient.core.exception.OSchemaException: Cannot change the schema while a transaction is active. Schema changes are not transactional
at com.orientechnologies.orient.core.metadata.schema.OSchemaShared.saveInternal(OSchemaShared.java:956)
at com.orientechnologies.orient.core.metadata.schema.OSchemaShared.releaseSchemaWriteLock(OSchemaShared.java:751)
at com.orientechnologies.orient.core.metadata.schema.OSchemaShared.doCreateClass(OSchemaShared.java:385)
at com.orientechnologies.orient.core.metadata.schema.OSchemaShared.createClass(OSchemaShared.java:314)
at com.orientechnologies.orient.core.metadata.schema.OSchemaProxy.createClass(OSchemaProxy.java:77)
at com.tinkerpop.blueprints.impls.orient.OrientElement$1.call(OrientElement.java:469)
at com.tinkerpop.blueprints.impls.orient.OrientElement$1.call(OrientElement.java:465)
at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.executeOutsideTx(OrientBaseGraph.java:1658)
at com.tinkerpop.blueprints.impls.orient.OrientElement.checkForClassInSchema(OrientElement.java:465)
at com.tinkerpop.blueprints.impls.orient.OrientEdge.getClassName(OrientEdge.java:474)
at com.tinkerpop.blueprints.impls.orient.OrientEdge.createDocument(OrientEdge.java:511)
at com.tinkerpop.blueprints.impls.orient.OrientEdge.convertToDocument(OrientEdge.java:441)
at com.tinkerpop.blueprints.impls.orient.OrientEdge.setProperty(OrientEdge.java:314)
at com.tinkerpop.frames.annotations.PropertyAnnotationHandler.processElement(PropertyAnnotationHandler.java:34)
at com.tinkerpop.frames.annotations.PropertyAnnotationHandler.processElement(PropertyAnnotationHandler.java:11)
at com.tinkerpop.frames.FramedElement.invoke(FramedElement.java:89)
at com.sun.proxy.$Proxy7.setWeight(Unknown Source)
at com.spicegraph.test.domain.test.DbTest.addNewStuffToDb(DbTest.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
I'm using OrientDb as the graph provider. What could have possible gone wrong?
Here is my code:
public interface Ingredient extends VertexFrame{
@Property("name")
public String getName();
@Property("name")
public void setName(String name);
@Adjacency(label="usedwith", direction=Direction.BOTH)
public Iterable<Ingredient> getUsedWithIngredient();
@Adjacency(label = "usedwith")
public Ingredient addUsedWithNewIngredient();
@Incidence(label = "usedwith")
public UsedWithEdge addUsedWithIngredient(final Ingredient person);
@Adjacency(label = "usedwith")
public void removeUsedWithIngredient(final Ingredient person);
@Incidence(label = "usedwith")
public void removeUsedWith(final UsedWithEdge usedWith);
}
public interface UsedWithEdge extends EdgeFrame {
@Property("weight")
public void setWeight(int weight);
@Property("weight")
public int getWeight();
@OutVertex
Ingredient getOutIngredient();
@InVertex
Ingredient getInIngredient();
}
and this is a snippet of the test case
Ingredient v1=framedGraph.addVertex(null, Ingredient.class);
Ingredient v2=framedGraph.addVertex(null, Ingredient.class);
v1.setName("cumin");
v1.setConservAndStoring("conservation yearly");
v1.setPrepAndUse("prep prep ");
v2.setName("cinnamon");
v2.setAbout("about is about");
v2.setConservAndStoring("conservation is daily");
UsedWithEdge edge=v2.addUsedWithIngredient(v2);
edge.setWeight((1)); // << error is thrown here !!
framedGraph.getBaseGraph().commit();
This is an OrientDb problem. I used OrientGraphNoTx
OrientGraphNoTx graph=new OrientDbGenericDao().graphInstance();
FramedGraphFactory factory = new FramedGraphFactory(); // make sure you reuse the factory when creating new framed graphs.
framedGraph = factory.create(graph); // wrap the base graph
and it worked pretty well.