我想复制多个节点,然后同时删除旧节点。为此,我编写了一个多线程 Java 应用程序。我的密码查询如下:
String cypher= "MATCH (a:Person {surname:\""+ Thread.currentThread().getName()+"\"})
create (b:Person)
set b.surname=a.surname
SET b.version = '2'
WITH a,b
MATCH (a)-[r:has_indication]->(c)
WITH COLLECT(r) AS rels, a, b, c
FOREACH (rel in rels |
CREATE (b)-[r2:has_indication]->(c)
SET r2+=rel
)
with a,b,c
MATCH (c)-[r3:has_indication]->(a)
WITH COLLECT(r3) AS rels2, a, b, c
FOREACH (rel in rels2 |
CREATE (c)-[r3:has_indication]->(b)
SET r3+=rel
)
DETACH DELETE a " ;
我的java代码如下:
public void run() {
Driver driver = GraphDatabase.driver(
"bolt://localhost:7687", AuthTokens.basic("neo4j", "neo4j"));
Session session = driver.session();
session.runAsync( cypher);
}
我使用 3 个线程,当三个节点相互关联时,只有一个节点被更新,但是当这些节点相互不关联时,三个节点都成功更新。即使它们同时相互关联,我如何更新它们?我正在使用 neo4j 企业版 3.4.7 。