Return boolean value from Cypher query and spring data repository method

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?

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.