7

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.

biesior
  • 55,576
  • 10
  • 125
  • 182
coolsuntraveler
  • 317
  • 5
  • 13

1 Answers1

9

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();
biesior
  • 55,576
  • 10
  • 125
  • 182