I have following problem: I have almost the same two reports created by sql view joing few tables together. This query looks like: SELECT sth_not_important, ARRAY(SELECT sd.date from scr2.schedule_dates sd WHERE sth_not_important AND sd.date>=now() ORDER BY sd.date) as dates FROM public.users few not important INNER JOIN...
The most important is the bolded part sd.date>=now() which is presented only in one report. The second one differs only in that it doesn't contain that condition. So the simplest solution would be to have parameterized query with one parameter for sd.date>=now(), so then it would be only one view for both reports.
The second solution is to have two collections for both dates:
<property name="allDates" lazy="true" formula="ARRAY(SELECT sd.date from scr2.schedule_dates sd WHERE sth_not_important ORDER BY sd.date" /> <property name="nextDates" lazy="true" formula="ARRAY(SELECT sd.date from scr2.schedule_dates sd WHERE sth_not_important AND sd.date>=now() ORDER BY sd.date" /> - for condition sd.date>=now()
But unfortunately it doesn't work... It seems that there is a bug in hibernate - it runs both of these formulas while the view is got from database despite they are labeled as lazy. This view is POJO with subselect as view. Do anybody have any idea how can I solve this?? Is there any possibility to set parameter to external query (like subselect in hibernate mapping)?? I don't want to use named query or to glue many conditions in java, I want to use criterias and restrictions. I still have to do many hard reports of the same type as discribed in this post, so I will be gratefull if sb tell me how to do it nice and fast :)
|