-->
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.  [ 9 posts ] 
Author Message
 Post subject: How to supply an Array or Collection to a named filter?
PostPosted: Mon Sep 06, 2004 1:24 pm 
Newbie

Joined: Wed Sep 01, 2004 3:06 am
Posts: 9
I'm trying to figure out the best way to provide a filtering to a collection-retrieval process. Imho, the filter/filter-dev combination is quite nice and basically what I need.

The only problem is, that one of the filters needs a variable list/set/array of inputs which I want to do via the SQL IN-operator.

I'd like to achieve something like this:
Code:
    <filter-def name="documentType">
        <filter-param name="documentTypeIDs" type="set" />
    </filter-def>

    <filter name="documentType" condition="documentTypeID IN (:documentTypeIDs)" />


But I can't figure out how to get that to work, the reference documentation and hibernate in action don't seem to mention this either. Nor was I able to find it using the forum's searchengine.

I've also tried specifying type="long" and simply supplying an array of Long's.

Actually, what I really'd like to achieve is a filter like this (using a Map orso), but that seems to be even more out of reach:
Code:
(documentID, documentTypeID) IN ((x1, y1), (x2, y2), ... )


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 17, 2004 8:14 pm 
Newbie

Joined: Wed Nov 17, 2004 1:27 pm
Posts: 1
I'm trying to figure out how to do this too, so if anyone knows please post it!

Most of the things I have tried ended with hibernate blowing up saying "Undefined filter parameter" but if I pack up an ArrayList an pass it into .setParameter() and define the type as "java.util.ArrayList" in the filter-def it doesn't blow up but it doesn't return any records either.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 23, 2004 6:17 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
I'm playing with this case as well, if anyone has some updates how to get this up and running I would be very thankful.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 28, 2004 1:54 pm 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
I have just heard that this feature is not supported yet and i have raised a jira request for it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 06, 2005 7:15 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Steve Ebersole fixed this issue in Beta 2, maybe you want to read the comments in JIRA Post HHH-77


Top
 Profile  
 
 Post subject: What is the filter-param type for collections?
PostPosted: Fri Aug 12, 2005 1:49 pm 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
What is the filter-param type for collections? does anyone know? set doesn't appear to work.


Top
 Profile  
 
 Post subject: You can do like following. (Don't forget to rate answer)
PostPosted: Sat Aug 27, 2005 12:34 pm 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
You can do like following. (Don't forget to rate answer)

session.enableFilter("secure")
.setParameterList("networkPlanIds", applicationUser.getNetworkPlanIds())


Top
 Profile  
 
 Post subject: Also in filter-def
PostPosted: Sat Aug 27, 2005 12:36 pm 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
You give the type to be type of individuals in list. i.e:

<filter-param name="networkPlanIds" type="long"/>


Top
 Profile  
 
 Post subject: How to supply an Array or Collection to a named filter?
PostPosted: Thu Jan 19, 2006 1:59 pm 
Newbie

Joined: Thu Jan 19, 2006 1:43 pm
Posts: 1
Location: Chicago
Right, you need to set the filter type first, then set the parameter. For example, set this in the class for filtering a client table based on client ID:

<filter name="keyListFilter" condition="CLIENT_ID IN (:keyListParam)"/>

Then set this filter param, pass in a list identified by the name keyListParam and specify the type of values in the list:

<filter-def name="keyListFilter">
<filter-param name="keyListParam" type="long"/>
</filter-def>

Watch out for the type! You may think you are passing a list of "Long" objects, but in my experience somehow the array got converted to a list of primitive type "long" values.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.