簡體   English   中英

Tinkerpop框架:事務處於活動狀態時無法更改架構

[英]Tinkerpop frames: Cannot change the schema while a transaction is active

我正在測試Tinkerpop框架。 我的關系類似於“人認識人”,但是每次我測試代碼時,都會出現此錯誤

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)

我正在使用OrientDb作為圖形提供程序。 有什么可能出錯了?

這是我的代碼:

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

這是測試用例的一個片段

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

這是一個OrientDb問題。 我用了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

而且效果很好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM