-->
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.  [ 7 posts ] 
Author Message
 Post subject: Error with simple math in HQL
PostPosted: Mon Aug 15, 2005 6:45 am 
Beginner
Beginner

Joined: Wed Feb 16, 2005 1:22 am
Posts: 25
Location: Jakarta
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
Hibernate 3.0.5

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hi,
I'm just curious with this HQL statement

select (20 + 10) - (10 + 10) from BdpInTransitBlncItems A

In normal sql statement, this will result in 30 - 20 == 10, but the result from hql is 30. It is as if the parantheses dont work.

Please guide mee...

_________________
Greater in battle
than the man who would conquer
a thousand-thousand men,
is he who would conquer
just one —
himself.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 10:16 pm 
Beginner
Beginner

Joined: Wed Feb 16, 2005 1:22 am
Posts: 25
Location: Jakarta
Here is the output after setting show_sql to true

Hibernate: select 100+10-10*10 as col_0_0_ from BDP_IN_TRANSIT_BLNC_ITEMS bdpintrans0_

I wonder why the parentheses supplied in hql are removed ? Is this the normal behaviour ? I tried out both OracleDialect and Orache9Dialect, and the results are the same. Is there a configuration stating that the parentheses' removal behaviour ?

Please, it's very urgent ... T-T

_________________
Greater in battle
than the man who would conquer
a thousand-thousand men,
is he who would conquer
just one —
himself.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 10:49 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Bad Hibernate!

I'll fix it ;)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 11:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Fixed in CVS:

http://opensource.atlassian.com/project ... se/HHH-868


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 12:14 am 
Beginner
Beginner

Joined: Wed Feb 16, 2005 1:22 am
Posts: 25
Location: Jakarta
Hi,

That was quick !

Thanks alot !

^-^

_________________
Greater in battle
than the man who would conquer
a thousand-thousand men,
is he who would conquer
just one —
himself.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 07, 2005 2:57 pm 
Newbie

Joined: Fri Oct 07, 2005 2:45 pm
Posts: 1
Hi Guys,

I am using hibernate 3.1 beta 2. I found a similar parentheses related problem. My HQL looks something like:

select pb.person
from PersonBenefit pb
where
pb.person.app.id = :appKeyId and
( (pb.ben.code = :healthBenCd1 and pb.flag1 = :flagval1) or
(pb.ben.code = :healthBenCd2 and pb.flag1 = :flagval2 and pb.person.prsnFlag = :flagVal3) )

when Hibernate translates in HQL into SQL it strips off the inner parentheses. The where clause looks something like -

where..........
.........
pb.person.app.id = :appKeyId and
(pb.ben.code = :healthBenCd1 and pb.flag1 = :flagval1 or
pb.ben.code = :healthBenCd2 and pb.flag1 = :flagval2 and pb.person.prsnFlag = :flagVal3 )

Has anybody faced a similar problem? Thanks for your help


Top
 Profile  
 
 Post subject: CVS
PostPosted: Fri Nov 18, 2005 1:13 am 
Newbie

Joined: Mon Aug 15, 2005 7:53 pm
Posts: 8
Location: Córdoba, Argentina
Hi... I have the same problem in a HQL query, Hibernate is eliminating the internal parenthesis... I see you could fix it, and I want to know how can I get that fix from CVS repository, or if I have to download the beta 2 to get the fix.

Thanks in advance


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