Hi all,
First of all sorry for my bad english :)
I'm trying to execute a query with a case...when in the select side. It's similar to the following:
select new map (table1.codTable1 as cod1, table1.descTable1 as desc1,
CASE table1.typeTable1
WHEN 'A' THEN (select descType from tableTypesA typeA where typeA.cod = table1.codTable1)
WHEN 'B' THEN (select descType from tableTypesB typeB where typeB.cod = table1.codTable1)
END as type1)
from tableData1 table1
It returns me this error:
Code:
Caused By: org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: query [Select...]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:82)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:261)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
Truncated. see log file for complete stacktrace
I tried to change 'then' sentences to a literal and it works for me, but with a subquery is impossible?
I'm ussing hibernate 3.3.2
Thanks a lot