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.  [ 2 posts ] 
Author Message
 Post subject: How to use parameterized query not using named query
PostPosted: Mon Nov 15, 2010 11:16 am 
Newbie

Joined: Thu Oct 28, 2010 3:54 am
Posts: 2
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 :)


Top
 Profile  
 
 Post subject: Re: How to use parameterized query not using named query
PostPosted: Tue Nov 16, 2010 11:54 am 
Newbie

Joined: Thu Oct 28, 2010 3:54 am
Posts: 2
Has anybody any idea how to solve it??


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.