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
|
|