-->
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: Grammar/HQL coalesce question
PostPosted: Wed Jan 14, 2009 12:45 pm 
Newbie

Joined: Wed Jan 14, 2009 12:32 pm
Posts: 2
Hi all.
Im new(noob) with hibernate and im trying to write this code in HQL but isnt working right:


In DB2:
SELECT *
FROM TABLE
WHERE column = COALESCE(CAST(variable AS INT), column)



In HQL I wrote:
select t from Table t where t.column = coalesce(cast(?1 as integer), t.column)


But in HQL doenst work correctly when I send a null value, ant this exception rise:

org.springframework.orm.jpa.JpaSystemException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 5:41 am 
Newbie

Joined: Wed Jan 14, 2009 12:32 pm
Posts: 2
FRACOS.


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.