cancel
Showing results for 
Search instead for 
Did you mean: 

Return boolean value from Cypher query and spring data repository method

myshareit
Node Clone

I have the following query which works fine:

@Query( "....(d)-[rdpr:CONTAINS*]->(pr) " +
        "RETURN count(rdpr) > 0 as c")
boolean hasPermission(...);

now I'd like to extend the return statement with something like this:

@Query("....MATCH (d)-[rdpr:CONTAINS*]->(pr) " +
        "RETURN CASE be.secured WHEN false THEN true ELSE (count(rdpr) > 0) END as allowed")
boolean hasPermission(...);

but it fails with the following error:

org.springframework.aop.AopInvocationException: Null return value from advice does not match primitive return type for: public abstract boolean com.example.domain.repository.neo4j.system.security.permission.PermissionRepository.hasPermission(..)

What am I doing wrong and how to fix it?

1 REPLY 1

gerrit_meier
Neo4j
Neo4j

The result pattern ^^ returns NULL in some cases and thus cannot be mapped to the primitive boolean type. If you say, alright NULL is a valid return value, you would have to use a Boolean class instead of the primitive.