-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Case ... when in Hibernate
PostPosted: Wed Dec 04, 2013 5:51 am 
Newbie

Joined: Wed Dec 04, 2013 5:09 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.