简体   繁体   中英

neo4j: user defined procedure exception “Write operations are not allowed for `READ` transactions”

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!

From inspecting the APOC user defined procedures, I learned the answer. I am using neo4j 3.0.7, for 3.0.xa 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM