-->
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.  [ 3 posts ] 
Author Message
 Post subject: Filtering one-to-many collection
PostPosted: Wed Jul 08, 2009 3:44 am 
Newbie

Joined: Thu Feb 07, 2008 6:48 am
Posts: 14
Hello,

I would like to filter the <many-to-one> relation with the <filter name="bla" condition=":par = PROPERTYNAME" />

The problem is that I do not always have to filter the set with "=".
Sometimes I want to filter with the ">" operator. Or the "<" operator.

Do I really have to add:
<filter name="filterEq" condition=":par = PROPERTYNAME" />
<filter name="filterGt" condition=":par > PROPERTYNAME" />
<filter name="filterLt" condition=":par < PROPERTYNAME" />

For EVERY property name???

Is there another way to do this?

Regards
M


Top
 Profile  
 
 Post subject: Re: Filtering one-to-many collection
PostPosted: Wed Jul 08, 2009 6:46 am 
Newbie

Joined: Tue Jun 02, 2009 4:06 am
Posts: 16
Hi,
I am not clear about your requirement.If you can attach your hbm.xml then it would be great.
You can use "Between" operator rather than using > or < than operator as folows:

<filter-def name="effectiveDate">
<filter-param name="asOfDate" type="date"/>
</filter-def>


<set name="employees" lazy="true">
<key column="dept_id"/>
<one-to-many class="Employee"/>
<filter name="effectiveDate"
condition="asOfDate BETWEEN eff_start_dt and eff_end_dt"/>
</set>

where eff_start_dt and eff_end_dt are the properties of that class.

I hope it helps.

Thanks
Kartik


Top
 Profile  
 
 Post subject: Re: Filtering one-to-many collection
PostPosted: Wed Jul 08, 2009 7:03 am 
Newbie

Joined: Thu Feb 07, 2008 6:48 am
Posts: 14
Hello,

Thanks for your quick reply. But this is not what I meant.
I'm generating the hbm files dynamically. So I do not know what the user wants to filter.

Let's say we have a <many-to-one> with Items.
An item looks like
String property1;
int property2;
DateTime property3;
...

Sometimes the user wants to filter on property1 == "Name";
Sometimes the user wants to filter on property1 LIKE "Na%";
Sometimes the user wants to filter on property2 == 1;
Sometimes the user wants to filter on property2 > 1;

So the filtering is dynamic.

The only solution for me is to provide filters for EVERY type and EVERY property:

<filter name="stringEqFilter" condition = ":par = Title" />
<filter name="stringGtFilter" condition = ":par > a />
...
<filter name="intEqFilter" condition = ":par = 1" />
<filter name="intGtFilter" condition = ":par > 1" />
...

So this is a little bit overkill.

Is there a way to do this differently. Something like:

<filter name="stringFilter" condition= ":par" />
where the :par parameter can be filled in dynamically.
Like :par equal to "Title = MacGyver"
But that doensn't work

Regards,


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.