值和类型

过程或函数的输入输出必须是支持的类型之一,如 Cypher 手册 → 值和类型中所述。

复合类型通过以下方式支持:

  • List<T>,其中 T 是受支持的类型之一;以及

  • Map<String, Object>,其中映射中的值必须是受支持的类型之一。

当事先不知道类型时,支持使用 Object。但是请注意,实际值仍必须是上述类型之一。

表 1. 支持的 Cypher 类型及其在 Java 中的对应类型
Cypher 类型 Java 类型

String

String

Integer

Long

Float

Double

Boolean

Boolean

Point

org.neo4j.graphdb.spatial.Point

Date

java.time.LocalDate

Time

java.time.OffsetTime

LocalTime

java.time.LocalTime

DateTime

java.time.ZonedDateTime

LocalDateTime

java.time.LocalDateTime

Duration

java.time.temporal.TemporalAmount

Node

org.neo4j.graphdb.Node

Relationship

org.neo4j.graphdb.Relationship

Path

org.neo4j.graphdb.Path

有关更多详细信息,请参阅 Neo4j Javadocs org.neo4j.procedure.Procedure

在两种情况下,多个 Java 类型会映射到单个 Cypher 类型。发生这种情况时,类型信息会丢失。如果过程返回以下对象,则无法重新创建原始类型:

  • 当提供 java.time.Durationjava.time.Period 时,会创建一个 Cypher Duration。如果返回 Duration,则只保留公共接口 java.time.temporal.TemporalAmount

  • 当提供 java.time.OffsetDateTime 时,会创建一个 Cypher DateTime。如果返回 DateTime,它将被转换为 java.time.ZonedDateTime

© . All rights reserved.