Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

filterMany for Play 2 returns all results

I am using Play 2.0.2 with ebean.

In Info class, I defined

@ManyToMany(fetch=FetchType.EAGER)
private Set<MemberInfo> members;

private Date createdDate = new Date();

And MemberInfo has memberId field.

When I do

public static Finder<Long,Info> find 
        = new Finder<Long,Info>(Long.class, Info.class);

find.fetch("members")
    .where().filterMany("members").eq("memberId", memberId)
    .order().desc("createdDate")
    .findList();

It returns all Info, without checking memberId of members.

What did I do wrong? Thanks.

like image 796
coolsuntraveler Avatar asked Jul 28 '12 18:07

coolsuntraveler


1 Answers

filterMany() doesn't filter parent results by children's expressions (both has separate 'ranges').

As descriped in its API it will find all Info objects and filtered members for each.

There is also very similar topic on Google Groups where author of the question gives his own workaround for this.

Examine the difference between:

find.fetch("members")
    .where().filterMany("members").eq("memberId", 1L)
    .findList();

and

find.fetch("members")
    .where().eq("members.memberId", 1L)
    .findList();
like image 84
biesior Avatar answered Nov 03 '22 01:11

biesior