neo4j / sdn-rx

Nextgen Spring Data module for Neo4j supporting (not only) reactive data access and immutable support
https://neo4j.github.io/sdn-rx
Apache License 2.0
65 stars 23 forks source link

Getting "The mapper returned a null value." #240

Closed benkuly closed 4 years ago

benkuly commented 4 years ago

Description When I write custom queries with ReactiveNeo4jTemplate or with @Query I get a Nullpointer with "NullPointerException: The mapper returned a null value."

How to reproduce? You find my failing test here: https://github.com/benkuly/matrix-sms-bridge/blob/9cb2a645e0eea1d77e3692421ad06c4589eb6da3/src/test/kotlin/net/folivo/matrix/bridge/sms/mapping/SmsRoomRepositoryIT.kt#L75 Also the other test fails, but maybe it solves, when we found a solution for this issue.

meistermeier commented 4 years ago

Thanks for reporting this. Instead of not getting any response, you are getting a real null value back. and this will (of course) fail for an expected Int signal. The supplied someUserId does not exist, but only someUserId1/2. But in the return clause you do a max call with the non-existing s.mappingToken that creates the null signal instead of e.g. an empty Mono. You could do something like RETURN coalesce(max(s.mappingToken), -1) to avoid this.

Idea: also appending WITH max(s.mappingToken) as maxi WHERE NOT maxi IS NULL RETURN maxi would work.

Does this solves the problem for you?

benkuly commented 4 years ago

Thank you very much :heart: WITH max(s.mappingToken) as maxi WHERE NOT maxi IS NULL RETURN maxi works perfect! Didn't know that there is a difference between null and "no answer" in neo4j. Maybe with this hint I can find more mistakes in the other not working queries.