-->
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.  [ 3 posts ] 
Author Message
 Post subject: setMaxResults set to subselect instead of main select
PostPosted: Fri Apr 01, 2005 7:04 pm 
Beginner
Beginner

Joined: Thu Jan 06, 2005 6:21 pm
Posts: 23
Hibernate version: 3.9 rc1

The following HQL:
from MyTable myTable
where myTable.name IN (select distinct otherTable.name from myTable otherTable where otherTable.id = :id)

Generates the following SQL
select mytable0_.id, ...
from MY_TABLE mytable0_
where (mytable0_.name IN(select distinct top 25 mytable1_.name from MY_TABLE mytable1_ where mytable1_.id = '4')

when the following code is ran:
Query query = session.createQuery(queryStr);
query.setFirstResult(1);
query.setMaxResults(25);
List result = query.list();

I believe the "top 25" should be set to the top select and not in the subselect.
How can I make sure the generated SQL looks like:
select top 25 mytable0_.id, ...
from MY_TABLE mytable0_
where (mytable0_.name IN(select distinct mytable1_.name from MY_TABLE mytable1_ where mytable1_.id = '4')

Thanks

Richard


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 01, 2005 8:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
oops, this is a bug.

But why on earth would anyone ever use "distinct" in a subselect??? Makes no sense...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 01, 2005 9:08 pm 
Beginner
Beginner

Joined: Thu Jan 06, 2005 6:21 pm
Posts: 23
The distinct is also a "bug" :)
I was just playing around and copied/pasted some other hql.

Richard


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