-->
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.  [ 1 post ] 
Author Message
 Post subject: hql logical condition translation problem
PostPosted: Wed May 24, 2006 11:28 am 
Newbie

Joined: Wed May 24, 2006 10:58 am
Posts: 2
Hello Everybody!

I've been using Hibernate for a while now, but this is my first posting to this forum. Hiberante is great, thank you! :) Still, I have a problem.

I'm trying to execute an HQL query which has subqueries. The generated SQL seems to be wrong.

Hibernate version:
3.2.CR2,
3.1

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

String q =
"from table1 where
not(
exists( from table2 )
or
exists( from table3 )
)"

s.createQuery(q).list();

Name and version of the database you are using:
Postgresql 8.1

The generated SQL (show_sql=true):

Hibernate:
select model_user0_.id as id1_, ...
from table1 model_user0_
where
(exists (select model_user1_.id from table2 model_user1_))
and
(exists (select model_user2_.id from table3 model_user2_))

So. The point is that Hibarnate seems to translate the HQL condition:

not( exists(...) or exists(...) )

into SQL by something like

exists(...) and exists(...)

that is obviously not the same thing.

If the SQL was :

not( exists(...) ) and not( exists(...) )

than it would be correct, I guess, but this is not happening.

By the way, the query shown here is just a demonstration, it does not make any sense, but it should still work. My real query is much more compicated that this, I'm just trying to focus on the problem by removing the unneccessary parts.

What do you think? Is it really an existing problem in Hibarnate or I am doing something wrong? I also checked out the latest(?) code from svn, but it produced the same results.

Thank you,
Marton


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.