-->
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.  [ 3 posts ] 
Author Message
 Post subject: Please help - Decode example in hql
PostPosted: Sat Dec 02, 2006 6:07 pm 
Newbie

Joined: Mon Nov 29, 2004 3:59 pm
Posts: 3
Hello,

I am trying to use decode in hql, if I can get this very simple statement to work, I can get my big query to work.

All I am trying to do is somthing like this to test the hql...

select decode (1, 1, 'one', 'not one') as number
from ResourceImpl

I am using Hibernate tool with eclipse to convert this hql to sql to verify my syntax, it shows an error
---------------------------------------------------------------------------------
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.MethodNode
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'decode' {originalText=decode}
\-[EXPR_LIST] SqlNode: 'exprList'
+-[NUM_INT] LiteralNode: '1'
+-[NUM_INT] LiteralNode: '1'
+-[QUOTED_STRING] LiteralNode: ''one''
\-[QUOTED_STRING] LiteralNode: ''not one''
-----------------------------------------------------------------------------------

If I use the decode in where clause, it works fine. I don't know what I am doing wrong. If I write an equivalent sql for the above hql, it works fine.
I spent a lot of time searching the web for examples, etc, but could not find any.

Any help would be greatly appreciated.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 03, 2006 11:07 pm 
Senior
Senior

Joined: Tue Aug 23, 2005 8:52 am
Posts: 181
Havent tried this, but it looks like you might have to define the "decode" function through your SessionFactory configuration which can then be used in the HQLs. Check out the testcase at
org.hibernate.test.hql.CriteriaHQLAlignmentTest's testClassicHQLAggregationReturnTypes function


Top
 Profile  
 
 Post subject: Decode
PostPosted: Mon Dec 04, 2006 3:40 pm 
Newbie

Joined: Sun Nov 19, 2006 6:55 pm
Posts: 9
I don't know how decode works but this error can surely be resolved by putting double quotes instead of single quote inseide decode function for values.


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