Is there any way to do the following in HQL:
SELECT
case when flag = true then SUM(col1) else SUM(col2)
FROM
myTable
yes case is working in HQL now (I am using 3.5.
Keywords like SELECT, FROM, and WHERE, etc., are not case sensitive, but properties like table and column names are case sensitive in HQL.
HQL queries are case insensitive; however, the names of Java classes and properties are case-sensitive HQL is used to execute queries against database.
Even correlated subqueries (subqueries that refer to an alias in the outer query) are allowed. Note that HQL subqueries can occur only in the select or where clauses. Note that subqueries can also utilize row value constructor syntax.
I guess you can (3.6, 4.3) [inline edit] ...for where-clauses:
"Simple" case,
case ... when ... then ... else ... end
, and "searched" case,case when ... then ... else ... end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With