Neo4j OGM Unable to process ZonedDateTime field on class my.class.Class. Check the mapping

Lionel Cichero :

I am trying to persist a @NodeEntity which has a field of type java.time.ZonedDateTime into my Neo4j database using the Bolt driver, but all I get is this warning message:

org.neo4j.ogm.context.EntityGraphMapper : Unable to process AT on class nz.co.class.project.point.Point. Check the mapping.

I am using the following libraries:

  • OpenJDK 11
  • Spring Boot (2.2.0.RELEASE)
  • Spring Data Neo4j (5.2.0.RELEASE)
  • Neo4j (3.5.12)
  • Neo4j-OGM (3.2.1)
  • Neo4j-OGM-Bolt-Driver (3.2.1)
  • Neo4j-OG-Bolt-Native-Types (3.2.1)

The result is the node entity being saved in the Neo4j database but without the ZonedDateTime attribute.

Am I doing something wrong? It is my understanding that OGM version 3.2.X supports all java dates in "java.time" package.

Here is a working example of the issue:

https://github.com/lcichero/neo4j-ogm-zoneddatetime.git

meistermeier :

Edit: The previous answer was not correct, sorry for this. I looked again into our sources because your comment gave me some doubts.

You need to explicitly enable the type conversion (this will get covered in the docs). For a Spring Boot application you can do this in the application.properties by adding

spring.data.neo4j.use-native-types=true

And you will see something like

Request: UNWIND {rows} as row CREATE (n:`Point`) SET n=row.props RETURN row.nodeRef as ref, ID(n) as id, {type} as type with params {type=node, rows=[{nodeRef=-2, props={x=14.5, y=43.5, at=2018-06-23T00:00+12:00}}]}

if you set the logging for org.neo4j.ogm to DEBUG.

For Neo4j-OGM the configuration would be

Configuration configuration = new Configuration.Builder()
    .uri("bolt://neo4j:password@localhost")
    .useNativeTypes()
    .build()

as described in the documentation.

Why do you have to explicitly enable this? Because we won't destroy and be able to read pre Neo4j-OGM 3.2 users' data in the database by storing the "new" native types instead of the converted values.

Old answer

We haven't yet published the 3.2. documentation, so I link to the sources on GitHub.

The supported temporal types are Date, Time, LocalTime, DateTime, LocalDateTime and Duration but as you can see not ZonedDateTime.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=322373&siteId=1