cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

run auto command using drivers or plugin

Hi guys,
I run this cypher with a browser and its works fine.

:auto MATCH (s:Person)-[r:Friend]->(t:Person) 
with s,t,collect(r) as rs
where size(rs) > 1
call{
with rs
CALL apoc.refactor.mergeRelationships(rs,{properties:{`.*`: 'discard'}}) YIELD rel RETURN count(*) as d
} IN TRANSACTIONS OF 100000 ROWS RETURN d

but when I run it in my plugin or java driver shows the below error

Caused by: org.neo4j.exceptions.SyntaxException: Invalid input ':':
":auto MATCH (s:Person)-[r:Friend]->(t:Person)"
^

And when I remove the :auto get this error:

A query with 'CALL { ... } IN TRANSACTIONS' can only be executed in an implicit transaction, but tried to execute in an explicit transaction.

How can I run cypher with auto command in java driver or plugin?

Thank you in advance for your attention

1 ACCEPTED SOLUTION

The 'call{} in transactions' clause only works with implicit transactions; as such, it will not work with a write transaction function. It will work in an implicit transition. Try executing the cypher using session.run(cypher, params) instead of session.writeTransaction(tx->tx.run(cypher, params)). It will not need ':auto' in this case. 

View solution in original post

2 REPLIES 2

The 'call{} in transactions' clause only works with implicit transactions; as such, it will not work with a write transaction function. It will work in an implicit transition. Try executing the cypher using session.run(cypher, params) instead of session.writeTransaction(tx->tx.run(cypher, params)). It will not need ':auto' in this case. 

Thank you

session.run(cypher, params) is work.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online