【问题标题】:Neo4j creating a node in a procedureNeo4j 在过程中创建节点
【发布时间】:2016-05-24 10:50:34
【问题描述】:

想知道我的事务是否需要配置以便它不是只读的......

在过程中创建节点时出现错误。错误是 原因:org.neo4j.graphdb.security.AuthorizationViolationException:READ 事务不允许写入操作。

调用该过程的测试是 -

@Test
public void testLoad() throws Exception {

    GraphDatabaseService db = new           TestGraphDatabaseFactory().newImpermanentDatabase();

    ((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency(Procedures.class)
            .register(LiveServiceLoad.class);

    Result res = db.execute("CALL load.hello()");

}

导致错误的过程 -

 @Procedure 
public Stream<Output> loadTimeTable() {
 try ( Transaction tx = db.beginTx() )
        {
         Node liveServiceNode = db.createNode(Label.label("LiveService"));

【问题讨论】:

    标签: neo4j transactions procedures


    【解决方案1】:

    您需要将@PerformsWrite 注解添加到对图进行变异操作的任何过程。

    https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/master/src/main/java/apoc/create/Create.java#L27 为例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多