问题
I have implemented a user defined procedure using the example template.
The procedure is annotated using "@Procedure(value = "foo.bar", mode = Mode.WRITE)", nevertheless, when I try to execute an operation on a Node instance that modifies the graph, it fails with "Write operations are not allowed for READ
transactions".
The node instance was obtained via db.findNode(...), and the write-operation that I am attempting to execute is nodeinstance.createRelationshipTo(...)
Interestingly, the code works fine when run in the context of the neo4j testing harness.
Any help greatly appreciated!
回答1:
From inspecting the APOC user defined procedures, I learned the answer. I am using neo4j 3.0.7, for 3.0.x a procedure that wants to write to the graph must be annotated with "@PerformsWrites", as well as "@Procedure". The mode argument", mode = Mode.WRITE", is for 3.1, and "@PerformsWrites" is for 3.0.x -- learned this from Stefan Armbruster
来源:https://stackoverflow.com/questions/42257822/neo4j-user-defined-procedure-exception-write-operations-are-not-allowed-for-r