-->
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: limit issue (? N + 1 problem ?)
PostPosted: Wed Aug 30, 2006 2:29 am 
Newbie

Joined: Tue Jul 11, 2006 4:22 pm
Posts: 9
hellou i have a 2 tables ...

doctors and contacts -- mapping is 1 - N
i need to list 10 doctors on page and also show their contacts on the same page. So it would be great to achive it by one query like this :

--- postgresql grammar
select * from (select * from doctor where lastname like 'A%' order by lastname,name limit 10 offset 20) as a, contactdoctor b where b.doctor_id = a.id

the result of this query is minimum 10 results if one doctore have 1 contact. More that 10 results if doctor have more that one contact, but still only 10 doctors.

----
the problem is when i use setMaxResults and setFirstResult on hql query like this

select distinct doctor from Doctor doctor left join fetch doctor.contactdoctorSet contactdoctor where .....

i have everytime 10 results ... and the number of doctors is vary depend on number of the contacts ... i need the same result as on the standard sql query ...

cau any1 help plz ?


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.