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.  [ 2 posts ] 
Author Message
 Post subject: HQL case when then In select not parsing
PostPosted: Mon May 22, 2006 2:02 pm 
Newbie

Joined: Mon May 22, 2006 1:00 pm
Posts: 13
I am trying to use 'case when then' in a sql select, but the parser mistakes it for an alias. I see in the release notes for 3.0.4 (23.5.2005) that this should be possible:

* [HHH-467] - HQL: support for case when then else end IN select clause

Hibernate version: 3.1.2
Code between sessionFactory.openSession() and session.close():
String hql = "select "
//+ " ap.endDate "
+ " case when ap.endDate = 0 then 99999999 when ap.endDate != 0 then ap.endDate end "
//+ " case ap.endDate when 0 then 99999999 else ap.endDate end "
+ " from TargetTable ap ";
Full stack trace of any exception that occurs:
org.hibernate.QueryException: undefined alias: case [select case when ap.endDate = 0 then 99999999 when ap.endDate != 0 then ap.endDate end from com.alldata.ecis.persistence.AccountAgreementPremises ap ]
at org.hibernate.hql.classic.PathExpressionParser.token(PathExpressionParser.java:130)
Name and version of the database you are using: db2 as400


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 24, 2007 6:13 pm 
Newbie

Joined: Tue Apr 24, 2007 5:43 pm
Posts: 1
Ben - I tried similar query on IBM DB2 and "case" seems to work, you might have a type mismatch issue.

Code:
select
case when ap.endDate = null then '2030-01-01' else ap.endDate end
from TargetTable ap


Jeevs


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

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.