-
1. Re: dynamic finder method
jbossuser Jan 23, 2002 3:59 PM (in response to smirakr)Not sure what you mean by user filter. Do you mean you want your finder to return limited results based on user input? Or based on the user identity?
-
2. Re: dynamic finder method
smirakr Jan 24, 2002 4:50 AM (in response to smirakr)I mean limited results based on user input,
eg. on client side:
String query = "age > 15"; // client generates query dynamicaly
PeopleHome h = ... // obtain home of PeopleEntityBean which has a persistent attribute "age"
Collection beans = h.findByQuery(query); -
3. Re: dynamic finder method
jbossuser Jan 24, 2002 1:22 PM (in response to smirakr)I do something similar to this, but I have developed a reflection framework and utilize a HashMap value object that allows my client side to know what properties are available from a given bean. I couldn't find anything for free in the EJB spec to satisfy this need.
-
4. Re: dynamic finder method
dsundstrom Jan 29, 2002 3:36 PM (in response to smirakr)This is on the features list, but is a very low priority. In the mean time, I suggest that you write a BMP style cutom finder. Just declare your finder in the home and then provide an implementation in you bean implementation class. The method is named ejbFind(your args). This is a pain because you have to write some JDBC code, but usually an application only needs a couple of dynamic finders.
-
5. Re: dynamic finder method
abrasax Feb 27, 2002 11:23 AM (in response to smirakr)Hi,
I have a similar problem. I also use Hashtable structure for passing flexible parameters to my finder... I've written this finder using JDBC. I create the statement, get some ResultSet and return a collection of primary keys... This works for my BMP beans, but not for CMP2.0 beans. What kind of data is the BMP style finder in a CMP bean expected to return and how can I transform the primary keys into that? Can someone help me?
Best regards and thanks
Martin Stepanek -
6. Re: dynamic finder method
abrasax Feb 27, 2002 11:32 AM (in response to smirakr)Sorry, I found, what was wrong, just a few minutes after posting the yester post. I implemented the custom finder as a home method, ie. ejbHomeFindByAnything, instead of ejbFindByAnything, and so the container didn't transform the returned primary keys into proxies... Now it works fine :o) Mea culpa :o)
Martin -
7. Re: dynamic finder method
pazu Feb 27, 2002 10:22 PM (in response to smirakr)You may also want to look at the new EJB-QL query compiler and the Dynamic-QL feature. Take a look at this thread:
http://main.jboss.org/thread.jsp?forum=46&thread=9743