I have an @Repository interface with the following method of checking an IF database containing a collision of records (in the sense of a business domain) with one I am going to persist (I don't care that there are counter records):
@Query("select case when exists ( select me from MyEntity me where {my conditions regarding someParam here} ) then true else false end from MyEntity") boolean findColliding(@Param("someParam") String someParam);
The table in which I run it is empty (PostgreSQL), so the subquery exists should not find anything, and I believe that the whole method should return false as the case state, it can return true if it exists, and false otherwise.
It returns null #facepalm
My query passes a query syntax check at startup (without QuerySyntaxException), but throws an exception on execution:
org.springframework.aop.AopInvocationException: Null return value from advice does not match primitive return type for: public abstract boolean findColliding(...)
What am I doing wrong? Should I take a different approach to my problem?
Hibernate 5.0.11.Final
source share