java.lang.IllegalStateException:頂点またはタイプは、このトランザクションに関連付けられていません

スルー

フィールドは、インデックスを構築するときは、異常報告しました。
java.lang.IllegalStateException:頂点またはタイプがされていないこのトランザクションに関連付けられた[PERSON_NAME]

コード

StandardJanusGraph standardGraphFactory = GraphUtil.getStandardGraphFactory();
        JanusGraphManagement mgmt = standardGraphFactory.openManagement();
        VertexLabel person = mgmt.getVertexLabel("person");
        PropertyKey name = mgmt.getPropertyKey("person_name");
        mgmt = standardGraphFactory.openManagement();
        mgmt.buildIndex("person_name_index", Vertex.class).addKey(name).buildCompositeIndex();
        mgmt.commit();
        GraphTraversalSource g = standardGraphFactory.traversal();
        g.addV("person").property("birthDate", new Date(), "person_name", "limin");
        g.tx().commit();

例外情報

java.lang.IllegalStateException: The vertex or type is not associated with this transaction [person_name]

	at org.janusgraph.graphdb.transaction.StandardJanusGraphTx.verifyAccess(StandardJanusGraphTx.java:287)
	at org.janusgraph.graphdb.transaction.StandardJanusGraphTx.verifyWriteAccess(StandardJanusGraphTx.java:279)
	at org.janusgraph.graphdb.transaction.StandardJanusGraphTx.addEdge(StandardJanusGraphTx.java:701)
	at org.janusgraph.graphdb.transaction.StandardJanusGraphTx.addSchemaEdge(StandardJanusGraphTx.java:903)
	at org.janusgraph.graphdb.database.management.ManagementSystem.addSchemaEdge(ManagementSystem.java:231)
	at org.janusgraph.graphdb.database.management.ManagementSystem.createCompositeIndex(ManagementSystem.java:691)
	at org.janusgraph.graphdb.database.management.ManagementSystem.access$300(ManagementSystem.java:79)
	at org.janusgraph.graphdb.database.management.ManagementSystem$IndexBuilder.buildCompositeIndex(ManagementSystem.java:759)
	at cn.haizhi.bigdata.graph.client.DataInsertTest.testInsertDateData(DataInsertTest.java:59)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	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.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.junit.runner.JUnitCore.run(JUnitCore.java:160)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

トラブルシューティング

その理由は、インデックスが構築されたときに、ではないとの初めてのことであるstandardGraphFactory.openManagement()オープン・トランザクション、それがこの例外を報告します。単純にコードの後ろに置くmgmt = standardGraphFactory.openManagement();コメントアウトOK。
すなわち:

```java
StandardJanusGraph standardGraphFactory = GraphUtil.getStandardGraphFactory();
        JanusGraphManagement mgmt = standardGraphFactory.openManagement();
        VertexLabel person = mgmt.getVertexLabel("person");
        PropertyKey name = mgmt.getPropertyKey("person_name");
        mgmt.buildIndex("person_name_index", Vertex.class).addKey(name).buildCompositeIndex();
        mgmt.commit();
        GraphTraversalSource g = standardGraphFactory.traversal();
        g.addV("person").property("birthDate", new Date(), "person_name", "limin");
        g.tx().commit();
公開された38元の記事 ウォン称賛18 ビュー210 000 +

おすすめ

転載: blog.csdn.net/arlanhon/article/details/104474530