简体   繁体   中英

Can't delete Node with Cypher

i am working on Spring Data Neo4j and use Cypher-Language for some Queries. Works fine so long, but delete a Node don't work.

For Example:

@Query("start u=node(5) delete u")
void deleteNode();

i use the dependencies

<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-cypher</artifactId>
    <version>1.6.2</version>
</dependency>
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-kernel</artifactId>
    <version>1.6.2</version>
</dependency> 
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-neo4j</artifactId>
    <version>2.0.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-neo4j-rest</artifactId>
    <version>2.0.1.RELEASE</version>
</dependency>

i cannot use version 1.7.2 of Cypher because it conflict with spring data neo4j and the kernel 1.6.

Can anybody help me?

i don't want to delete a Node with

repository.delete(5);

Because i also want to delete Relationships and any more.

Thx!

I think you should delete the relationship with the node you want to delete. @Query("start u=node(5) delete u")

If you want to delete a node ,you should confirm the node haven't relationship with other node. Please have a try with following codes: @Query("start u=node(5) match u-[r]-() delete u,r")

Interesting idea, didn't try that yet b/c SDN still officially points to Neo4j 1.7 but that will change soon.

Why can't you update to SDN 2.1.RC2 ?

SDN 2.0.1 doesn't work with Neo4j 1.8 as there were API changes in Neo4j.

You will need to add @Transactional to the method as well.

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