java - HQL: select statement along with using 'case when then' giving unexpected token error -
i facing issue in writing hql query.
i have mysql table named mytable column names id , column1,column2 , type. fields integer type.
the select query based on value in 'type' column . if value in 'type' column  0 select query based value in column1. if value in type column 1 select query based on value in column2.
i have written query using 'case when then' sql successfully. same query giving exception when using hql query
sql query:
select *  mytable case when type=0 column1=234 when type=1       column2=564 end;   hql query:
from mytableobj obj case when obj.type=0 obj.column1=234 when obj.type=1 obj.column2=564 end;    gives following error,
 17:30:16,197 error [parser] line 1:127: unexpected token: =  17:30:16,198 error [parser] line 1:134: unexpected token: end  17:30:16,199 warn  [hqlparser] processequalityexpression() : no expression process!  org.hibernate.hql.ast.querysyntaxexception: unexpected token: = near line 1, column 127 [from mytableobj obj case when obj.type=0 obj.column1=234 when obj.type=1 obj.column2=564 end]     @ org.hibernate.hql.ast.querysyntaxexception.convert(querysyntaxexception.java:54)     @ org.hibernate.hql.ast.querysyntaxexception.convert(querysyntaxexception.java:47)     @ org.hibernate.hql.ast.errorcounter.throwqueryexception(errorcounter.java:82)     @ org.hibernate.hql.ast.querytranslatorimpl.parse(querytranslatorimpl.java:281)     @ org.hibernate.hql.ast.querytranslatorimpl.docompile(querytranslatorimpl.java:180)     @ org.hibernate.hql.ast.querytranslatorimpl.compile(querytranslatorimpl.java:134)     @ org.hibernate.engine.query.hqlqueryplan.<init>(hqlqueryplan.java:101)     @ org.hibernate.engine.query.hqlqueryplan.<init>(hqlqueryplan.java:80)     @ org.hibernate.engine.query.queryplancache.gethqlqueryplan(queryplancache.java:94)     @ org.hibernate.impl.abstractsessionimpl.gethqlqueryplan(abstractsessionimpl.java:156)     @ org.hibernate.impl.abstractsessionimpl.createquery(abstractsessionimpl.java:135)     @ org.hibernate.impl.sessionimpl.createquery(sessionimpl.java:1650)   thanks in advance
i did similar, value of condition same, thing changes according value in db column. here example:
select t.* table t case when t.column1 = 1    t.column2    else t.column3 end = 123;   this worked me. if want value (123 in example) dependent on condition column, can use case statement too.
check this example in sql, should work hql well.