Spring data neo4j cypher 方言并未在所有地方强制执行

问题描述 投票:0回答:1

升级到 Neo4j v5.9.0 时,我尝试通过创建以下配置来强制执行 Neo4j v5 方言,如文档建议的那样

import org.neo4j.cypherdsl.core.renderer.Dialect
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.neo4j.cypherdsl.core.renderer.Configuration as CypherConfiguration

@Configuration
class Neo4jConfiguration {

    @Bean
    fun cypherDslConfiguration(): CypherConfiguration =
        CypherConfiguration.newConfig().withDialect(Dialect.NEO4J_5).build()
}

从弹簧执行器检查时,似乎存在以下 bean

"cypherDslConfiguration": {
  "aliases": [],
  "scope": "singleton",
  "type": "org.neo4j.cypherdsl.core.renderer.Configuration",
  "resource": "class path resource [com/foo/infra/neo4j/Neo4jConfiguration.class]",
  "dependencies": [
    "neo4jConfiguration"
  ]
}

当使用存储库查询时,我仍然收到来自各种不同查询的以下警告

Neo.ClientNotification.Statement.FeatureDeprecationWarning: This feature is deprecated and will be removed in future versions.
    UNWIND $__relationships__ AS relationship WITH relationship MATCH (startNode:`MyNode`) WHERE startNode.entityId = relationship.fromId MATCH (endNode) WHERE id(endNode) = relationship.toId MERGE (startNode)-[relProps:`BELONGS`]->(endNode) RETURN elementId(relProps) AS __elementId__
                                                                                                                                                                       ^
The query used a deprecated function: `id`.

节点上的

entityId
字段用
@Id
注释进行注释。

我还缺少一些配置吗?还是我的 cypherDslConfiguration bean 不正确?

相关版本:

  • org.springframework.boot:spring-boot-starter-data-neo4j 3.1.2
  • org.springframework.data:spring-data-neo4j 7.1.2
  • 科特林 1.9.0
java spring-boot kotlin neo4j spring-data-neo4j
1个回答
0
投票

请阅读此 Spring Data Neo4j 7.1 发行说明。

来自发行说明:

Neo4j 5 引入了新的、更通用的内部标识符, 跨多个共享 Neo4j 数据库安全工作。他们叫 元素 id 可以使用 Cypher 函数检索

elementId(n)
。在此过程中,
id(n)
Cypher 函数得到 已弃用。后者返回一个长值来标识节点和 关系。

我从他们的文档中理解的内容以要点的形式给出:

    Neo4j 的
  • id()
    函数用于返回 long 值。现在,由于
    id()
    函数已被弃用,因此将不再支持返回类型为
    long
    类型的 id 字段。

正确的数据模型应在

@Id
字段上包含
@GeneratedValue
id

例如:

@Node("model")
public class Model {

   @Id
   @GeneratedValue
   private String entityId;

   .......

}

请阅读上述文档以获取更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.