Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
348 views
in Technique[技术] by (71.8m points)

playframework 2.0 - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...