【问题标题】:Ebean filter list in @OneToMany relation@OneToMany 关系中的 Ebean 过滤器列表
【发布时间】:2015-06-27 09:56:51
【问题描述】:

我在通过多项选择过滤@OneToMany realations 中的列表时遇到问题。正是我有两个实体:

@Entity
public class Table1 extends Model {

@OneToMany
public List<Table2> table2;

}


   @Entity
   public class Table2 extends Model {

   @ManyToOne
   public Table1 table1;

   public String someValue;

   }

所以,我想获取 Table1 的所有对象,在它的 Table2 列表中,某个值有两个确切的值。例如:

查找所有 Table1 在 table2 中,someValue = 1 和 someValue =2

【问题讨论】:

    标签: java filter one-to-many ebean many-to-one


    【解决方案1】:
    List<Table1> filteredTable = Table1.find
        .fetch("Table2")
        .where()
        .eq("t1.someValue","1")
        .findList();
    

    【讨论】:

    • 虽然这段代码 sn-p 可以解决问题,但including an explanation 确实有助于提高帖子的质量。请记住,您是在为将来的读者回答问题,而这些人可能不知道您提出代码建议的原因。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多