I am using Spring neo4j and Java. I have @NodeEntity
on the classes I wish to persist. In some of these classes, I have data members annotated with @RelatedTo
and @Fetch
. I want to be able to delete one of my classes containing @NodeEntity
and delete all data memembers connected to it vi its @RelatedTo
and @Fetch
annotations. I have created a delete query in attempt to delete the node and its nodes connected to it via their relations:
@Query("start n = node:uid(uid={0}) "
+ "match n-[*]-x WITH x MATCH x-[r]-() "
+ "delete x,r")
public void deleteByUid(String uid);
This deletes the top level node and its relations, but leaves behind the nodes that were connected via the relationship to the top level node. How can I modify the query to do this with cypher?