-->
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.  [ 5 posts ] 
Author Message
 Post subject: count(distinct nvl(a,b)) problem on HQL
PostPosted: Thu Mar 27, 2008 4:27 pm 
Newbie

Joined: Thu Mar 27, 2008 4:20 pm
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version:3.2.6[/b]

[b]Name and version of the database you are using: oracle 9i[/b]

Hi I am trying to write a HQL with next lines:

select groupname, sum(value),
count(distinct nvl(id2, id1))
from table
group by groupname

When code run, it give me error as:

org.springframework.orm.hibernate3.HibernateQueryException: expecting CLOSE, found '(' near line 2, column 14 [ ......]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found '(' near line 3,

Codes can run when I put:
select groupname, sum(value),
count(distinct id1)
from table
group by groupname

Please give me a hint how to resolve it? Or is it a bug in hibernate?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 31, 2008 9:54 am 
Newbie

Joined: Thu Mar 27, 2008 4:20 pm
Posts: 2
anyone can help?


Top
 Profile  
 
 Post subject: I have the same issue
PostPosted: Fri Feb 06, 2009 5:07 pm 
Senior
Senior

Joined: Tue Aug 01, 2006 9:24 pm
Posts: 120
I am using
Hibernate 3
and oracle 10g

my hql is as follows

Code:
      String hql = "SELECT new "+SelectItem.class.getCanonicalName() +
         "((trim(str(ft.pkId)), ft.name) " +
         "FROM FeedType ft ORDER BY ft.pkId";




and my exception is this
2009-02-06 15:56:10,033 ERROR [org.hibernate.hql.PARSER] - <line 1:71: expecting CLOSE, found 'FROM'>
2009-02-06 16:01:23,024 ERROR [com.comanche.rules.dao.BRRuleDao] - <org.springframework.orm.hibernate3.HibernateQueryException: expecting CLOSE, found 'FROM' near line 1, column 71 [SELECT new javax.faces.model.SelectItem((trim(str(ft.pkId)), ft.name) FROM com.comanche.web.dao.beans.FeedType ft ORDER BY ft.pkId]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found 'FROM' near line 1, column 71 [SELECT new javax.faces.model.SelectItem((trim(str(ft.pkId)), ft.name) FROM com.comanche.web.dao.beans.FeedType ft ORDER BY ft.pkId]>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 7:55 pm 
Senior
Senior

Joined: Tue Aug 01, 2006 9:24 pm
Posts: 120
I found my problem. I have just been staring at code to long.

I had to many ( removed the first one on trim

"(trim(str(ft.pkId)), ft.name) " +

now it works


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 8:00 pm 
Senior
Senior

Joined: Tue Aug 01, 2006 9:24 pm
Posts: 120
binbinxunbao

I think your problem might be that nvl is an oracle function. I am not quite sure about this but I think you might have to register the function with hibernate. Take a look at these links they might help.

http://www.dba.5341.com/list/9/23031.html

http://opensource.atlassian.com/project ... e/HHH-2016

http://forums.hibernate.org/viewtopic.p ... 8713153582


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