【问题标题】:Can't delete Node with Cypher无法使用 Cypher 删除节点
【发布时间】:2012-07-30 15:22:21
【问题描述】:

我正在研究 Spring Data Neo4j 并使用 Cypher-Language 进行一些查询。可以正常工作这么久,但删除节点不起作用。

例如:

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

我使用依赖项

<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>

我不能使用 Cypher 的 1.7.2 版本,因为它与 spring data neo4j 和内核 1.6 冲突。

有人可以帮我吗?

我不想用

删除节点
repository.delete(5);

因为我还想删除关系等等。

谢谢!

【问题讨论】:

  • cypher 1.8 之前不支持更新操作,例如删除对不起,只使用 template.delete(5) 或原始 repository.delete(5)

标签: spring graph neo4j cypher


【解决方案1】:

我认为您应该删除与要删除的节点的关系。 @Query("start u=node(5) delete u")

如果你想删除一个节点,你应该确认该节点与其他节点没有关系。 请尝试以下代码: @Query("开始 u=node(5) 匹配 u-[r]-() 删除 u,r")

【讨论】:

    【解决方案2】:

    有趣的想法,还没有尝试过 b/c SDN 仍然正式指向 Neo4j 1.7,但很快就会改变。

    为什么不能更新到 SDN 2.1.RC2?

    SDN 2.0.1 不适用于 Neo4j 1.8,因为 Neo4j 中的 API 发生了变化。

    您还需要将@Transactional 添加到方法中。

    【讨论】:

      猜你喜欢
      • 2022-12-12
      • 2022-12-30
      • 1970-01-01
      • 2022-12-21
      • 2016-01-06
      • 1970-01-01
      • 2019-01-21
      • 2015-07-16
      • 2012-05-10
      相关资源
      最近更新 更多