So How to check if a collection is null in HQL? Simple example:
select * from Book book where title in (:titles)
So if titles is a single variable, I can do
select * from Book book where (:titles is null or title in (:titles))
But what if titles is a list/collection?
select * from Book book where (:titles is null or title in (:titles))
this won't work if titles is a list. After intense search, I tried is empty, size, and exists function, I also tried (:titles) is null option.
None of the above works. I know there is a hard coded way which is writing different query depends on the status of the titles list, if it is null, one query, and if it is null, another query. But that will produce a lot similar HQL queries with minor changes. And my use cases has few more lists to consider so it is not desired.
My question is it even possible to do the checking directly in HQL?