Hi all,
using the latest version of Hibernate, I am not sure how to handle this query:
select
TaskResources.PlanStartDate,
TaskResources.PlanEndDate,
TaskResources.PlanHours,
TaskResources.Resource as Role,
TaskResources.PlanResource as Person,
case when Tasks.TaskName like 'Budget%' then Projects.Title else Tasks.TaskName end Task,
case when Tasks.TaskName like 'Budget%' then Projects.Status else Tasks.Status end Status,
Projects.ProjectNumber,
Projects.Title,
Projects.Release,
Projects.Company,
Tasks.Assigned as 'Assigned Now',
Tasks.DocumentIdentifier
FROM Projects, Tasks, TaskResources
WHERE Tasks.ProjectNumber = Projects.ProjectNumber
AND TaskResources.TaskID = Tasks.TaskID
AND (Projects.Release like '%RELEASEARGUMENT%')
AND (Projects.Department='Sofico')
AND (TaskResources.PlanResource like '%PERSONARGUMENT%')
AND (TaskResources.PlanHours > 0)
AND (TaskResources.PlanResource <> '')
AND (TaskResources.PlanEndDate > getdate() - '%STARTDATEARGUMENT%')
AND (TaskResources.PlanStartDate <= getdate()+ '%ENDDATEARGUMENT%')
union
select VacationRequest.StartDate as PlanStartDate,
VacationRequest.EndDate as PlanEndDate,
Days*7.5 as PlanHours,
'*Vacation' as Role,
Users.LFName as Person,
'Officieel verlof 2008' as Name,
'Ongoing' as Status,
'02008' as ProjectNumber,
'Absence' as Title,
'' as Release,
'Sofico' as Company,
Users.LFName as 'Assigned Now',
'' DocumentIdentifier
from VacationRequest, Users
where VacationRequest."User" = Users.UserName
and (Users.Department = 'Sofico')
and (Users.LFName like '%PERSONARGUMENT%')
and (VacationRequest.Status = 'Approved')
and (VacationRequest.EndDate > getdate()- '%STARTDATEARGUMENT%'))
and (VacationRequest.StartDate <= getdate()+ '%ENDDATEARGUMENT%'))
order by PlanStartDate,Person
As you can see, it has two CASE stamenents and a UNION.
I have to produce a list on a HTML page with the results but I am not sure how to do this in Hibernate.
Due to the "complexity", would it be a good solution to go for scalar results? What would be the alternatives?
Thank you,
Steven
|