Hi there!
You probably won't remember, but about a week ago i posted here about a problem i had with createSQLQuery() and joined subclasses.
since i couldn't figure out how to do it at all i wrote an sql-statement that does the job and tried to read all objects with session.load().
now it turned out, that that's terribly slow and i'm trying to figure out if there's another way to do it.
Here's the SQL-Statement:
select T.technicianActorID as currentTechnician,
TAS.tbTechnicianAppointmentSlotsID as currentSlot,
TAS2.tbTechnicianAppointmentSlotsID as previousSlot, TAS3.tbTechnicianAppointmentSlotsID as nextSlot
from tbTechnician as T
left outer join tbTechnicianAppointmentSlots as TAS on TAS.technicianActorID = T.technicianActorID
left outer join tbTechnicianAppointmentSlots as TAS2 on TAS2.technicianActorID = TAS.technicianActorID and TAS2.timeTo <= TAS.timeFrom and TAS2.tbCalendarID = TAS.tbCalendarID and TAS2.technicianAppointmentStatus = 1
left outer join tbTechnicianAppointmentSlots as TAS3 on TAS3.technicianActorID = TAS.technicianActorID and TAS3.timeFrom >= TAS.timeTo and TAS3.tbCalendarID = TAS.tbCalendarID and TAS3.technicianAppointmentStatus = 1
where T.technicianNo in ( 1890, 0774, 9977 )
and TAS.tbCalendarID in ( 18, 19, 20, 21, 22 )
and TAS.technicianAppointmentStatus = 0
order by T.technicianActorID asc, currentDate asc, TAS.timeFrom asc, TAS2.timeFrom desc, TAS3.timeFrom asc
The reason why we couldn't do it with a hibernate query is because of the bold part. Hibernate doesn't seem to support the on-conditionals in joins. We checked and there's no way to express it in the where clause either.
Now, the query above works and is suuuper fast!!! The problem is to load the objects, primary keys of which are returned.
So the question is, Gavin, is there a way to do that with a hibernate query and if not, Max, is there a way to do that with a SQLQuery?
If you need more information please let me know.
kind regards,
Torsten
|