Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search for Collection-Members fails #30

Closed
GoogleCodeExporter opened this issue Mar 17, 2015 · 3 comments
Closed

Search for Collection-Members fails #30

GoogleCodeExporter opened this issue Mar 17, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

Scenario:
DB entity "Person" has a "many-to-many" assoziation "friends" which are
"Person".

How to search for persons which have a special friend X.

First I tried Filter.some("friends", Collection<X>) which results in
"**INVALID VALUE - NOT A FILTER: ..." .

I solved this by by doing something like 
Filter.some("friends", Filter.in("id", Collection<X.id()>))

Original issue reported on code.google.com by c.dittbe...@digitec.de on 13 May 2009 at 1:46

@GoogleCodeExporter
Copy link
Author

Are you saying that Filter.some("friends", Filter.in("id", Collection<X.id()>)) 
did 
work successfully and gave you the results you wanted?

Also, what do you mean by the "Collection<...>" syntax?

I'm sorry that the usage is sort of confusing for these filters. Hopefully I 
can get 
some better examples up sometime. In the mean time, both of the following 
options 
should work for your case. If not, then there may be a bug in the framework.

Filter.some("friends", Filter.equal("", X);
Filter.some("friends", Filter.equal("id", X.getId());

There is also a blog entry that has some more examples: http://java-generic-
dao.blogspot.com/2008/12/search-capability-needs-to-be-able-to.html

Original comment by dwolvert on 13 May 2009 at 7:23

@GoogleCodeExporter
Copy link
Author

>Are you saying that Filter.some("friends", Filter.in("id", 
Collection<X.id()>)) did 
>work successfully and gave you the results you wanted?

Yes it does.

Collection<X.id()> is my shortcut of:

List<Integer> idList = new ArrayList<Integer>(); 
for (X x : getCollectionOfTypeX()) { idList.add(x.getId());}
search.addFilter(Filter.some("friends", Filter.in("id", idList))));
search.addFetch("friends")

this works well but is "ugly" code. I prefer the example of your blog entry:

Filter.some("friends", Filter.in("", collectionOfFriends))

I think it could be more distinguishable if you provide something like
Filter.in(Collection<?> collection).

BTW many thanks for this very helpfull framework.

Original comment by c.dittbe...@digitec.de on 14 May 2009 at 5:16

@GoogleCodeExporter
Copy link
Author

Will not change API. Will add more examples of Filters to the documentation.

Original comment by dwolvert on 27 May 2009 at 6:47

  • Changed state: WontFix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant