如何解决如何在 Neo4J 的 Java 驱动程序中将 DateTime 值作为参数传递?
我使用的是 Neo4J Java 驱动程序
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>4.2.0</version>
</dependency>
我试图在参数映射中使用 DateTime 值作为值,大致如下:
// we have a timezone,unixTimestamp as epoch seconds and a simple key: "d"
final Instant instant = Instant.ofEpochSecond(unixTimestamp);
final ZoneId zoneId = ZoneId.of(timezone);
final zoneddatetime zonedValueDate = zoneddatetime.ofInstant(instant,zoneId);
// creating a DateTimeValue from zonedValueDate does not work either
return Map.of(key,zonedValueDate);
此地图用于 TransactionWork
之类的实例
public Map<String,Object> execute(Transaction tx) {
Result queryResult = tx.run(query,parameter);
// consuming results ...
// returning them as Map
}
但我得到了一个例外:
org.neo4j.driver.exceptions.ClientException: Property values can only be of primitive types or arrays thereof
A DateTime
或 zoneddatetime
should be allowed as parameter (here is another hint),但如何正确使用?
或者我必须创建一个像 this 这样的 DateTime 值:
datetime({year:1984,month:10,day:11,hour:12,timezone: 'Europe/Stockholm'})
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。