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