-->
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.  [ 4 posts ] 
Author Message
 Post subject: How can I use "case ... when...else...end" in hql?
PostPosted: Mon May 16, 2005 12:05 pm 
Newbie

Joined: Sun May 15, 2005 1:24 pm
Posts: 11
Hi,

I wanna use "case ... when...else...end" in query, I found in the document it is said supported, but i had no luck to make it work. The query i made is:

Code:
"Select t.id" +
                        t.nameCN, " +
                        "case when t.checked=1 then '是' else '否' end," +
                        "t.checked "+
                        "from Types t where t.carSerie.brand.manufacturer.id=? order by t.id"


Did anyone ever use this? Please help me out. THanks a lot.


Henry[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 16, 2005 7:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
No - case is not supported by all databases. Move this into the Domain object or you could use a property with a formula.

http://forum.hibernate.org/posting.php?mode=reply&t=942477


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 16, 2005 11:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Actually case is now supported on most DBs, and in HQL. But not yet in the select clause (there is an existing JIRA request for that).


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 17, 2005 10:51 am 
Newbie

Joined: Sun May 15, 2005 1:24 pm
Posts: 11
Thanks. I'm trying formula now.

david wrote:
No - case is not supported by all databases. Move this into the Domain object or you could use a property with a formula.

http://forum.hibernate.org/posting.php?mode=reply&t=942477


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.