Consider the following query in HQL:
SELECT m.id, (SELECT (COUNT(*) > 0) FROM SubqueryTable...) FROM MyTable AS m;
I need to return information as boolean from the select query inside the select with information whether there are any entries that satisfy that query.
The above query would work fine translated in SQL, but hibernate gives me an error. I can’t use comparison operators with an aggregate function.
What is the proper way to get the information from the subselect inside the select clause, in HQL?
Not sure how this can be transformed into HQL but your query could be written as:
But perhaps you could use this – which seems to be bypassing the problem as it is using
INTcolumns:You could also try with
EXISTS:or: