How to use Neo4J native types with SDN and OGM

Hi Peter.
Thanks for your question.

Currently, the Neo4j-OGM documentation points to Version 3.2 which has not been released yet. This is an error on our site.

Regarding the parameter binding: This is also a current bug in Neo4j-OGM on our site. Neo4j-OGM uses Jacksons ObjectMapper to convert parameters and that one doesn't know how do deal with JDK 8 types out of the box.

I solved this in my demo projects in the following way at the moment:

First of all: Fix the ObjectMapper. This will be done in 3.2 automatically:

To make this work, please add GitHub - FasterXML/jackson-modules-java8: Set of support modules for Java 8 datatypes (Optionals, date/time) and features (parameter names) to your classpath.
It should be automatically available with your Spring Boot 2.1.x setup anyway.

Second step, tell Neo4j-OGM to keep away from data types it can actually pass along to embedded and Bolt instances:

ParameterConversionMode is an undocumented feature for the most recent Neo4j-OGM version 3.1.6 that allows such a thing.

And last but not least, fix all the conversion mappings by providing No-Op converters that Spring Data Neo4j should keep alone:

Use it like this:

I'm really sorry for that hassle, but this is the only solution.

Things will improve greatly with Spring Data Neo4j Moore (5.2) and Neo4j-OGM (3.2) which will be released with Spring Boot 2.2.
Opt-in to native types will be a simple property you'll set in your Spring Config.

Best,
Michael.

5 Likes