-->
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: Problem with HQL bracket (disjunction)
PostPosted: Wed Jul 23, 2008 11:57 pm 
Newbie

Joined: Wed Jul 23, 2008 11:39 pm
Posts: 18
Hi all, I am trying to create a query using HQL .
I am not sure if it is just a beginner's problem but it really blocks my way.

Here is the SQL that I pass into the function getSession().createQuery() (for illustration purpose):

select key, val from mytable where ((1=1 and 2=2) or (3=3 and 4=4))

and here is the GENERATED SQL (from show_sql):

select mytable0_.key as col_0_0_, mytable0_.val as col_1_0_ from mytable mytable0_ where 1=1 and 2=2 or 3=3 and 4=4

(The brackets are all gone which gives totally different result from what I expect, I want condition 1 AND 2 together OR 3 AND 4 together)

I am using Hibernate 3.

Could anyone help?
Thank you very much.


Top
 Profile  
 
 Post subject: Re: Problem with HQL bracket (disjunction)
PostPosted: Thu Jul 24, 2008 12:21 am 
Newbie

Joined: Wed Jul 23, 2008 11:39 pm
Posts: 18
atchris wrote:
Hi all, I am trying to create a query using HQL .
I am not sure if it is just a beginner's problem but it really blocks my way.

Here is the SQL that I pass into the function getSession().createQuery() (for illustration purpose):

select key, val from mytable where ((1=1 and 2=2) or (3=3 and 4=4))

and here is the GENERATED SQL (from show_sql):

select mytable0_.key as col_0_0_, mytable0_.val as col_1_0_ from mytable mytable0_ where 1=1 and 2=2 or 3=3 and 4=4

(The brackets are all gone which gives totally different result from what I expect, I want condition 1 AND 2 together OR 3 AND 4 together)

I am using Hibernate 3.

Could anyone help?
Thank you very much.


http://www.databasedev.co.uk/sql-multip ... tions.html
I just found here that the operations order (Beginners level~), so the removing of brackets is CORRECT!.


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.