播放2的filterMany返回所有结果 [英] filterMany for Play 2 returns all results

查看:80
本文介绍了播放2的filterMany返回所有结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在ebean上使用Play 2.0.2.

I am using Play 2.0.2 with ebean.

Info类中,我定义了

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

private Date createdDate = new Date();

MemberInfo具有memberId字段.

当我这样做

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

它返回所有Info,而不检查membersmemberId.

It returns all Info, without checking memberId of members.

我做错了什么?谢谢.

推荐答案

filterMany()不会通过子级表达式(均具有单独的范围")过滤父级结果.

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.

Google网上论坛问题的作者为此提供了自己的解决方法.

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

检查两者之间的区别:

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

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

这篇关于播放2的filterMany返回所有结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆