I have the following JPAQL query running against Postgresql
Code:
select i from Institution i where i.name=:name
if I pass a value for :name then the query behaves as expected. If I pass null, the query returns no results no matter what. This is because the native query generated is
Code:
.... where i.name=null
which is incorrect and returns no values. The correct native sql should be
Code:
.... where i.name is null
. Is there a way to tell hibernate or JPA to handle nulls with the is null language instead of passing a null value to =:value?
Without this functionality, I can't use named queries and have to build them dynamically which diminishes the value of JPA in my opinion. Is there a better solution to this than what I am doing?