如何在TypedQuery中添加List类型的条件

时间:2016-02-03 22:59:45

标签: java hibernate hsqldb

我的实体具有以下属性:

@Table(name = "MY_TABLE")
public class MyTable {
  ......
  @OneToMany(mappedBy = "mytable", cascade = ALL, orphanRemoval = true)
  private List<MyAnotherTable> otherTableValues = new ArrayList<MyAnotherTable>();
  ......
}

现在我正在尝试将HSQL写为

TypedQuery<Share> q =
            getEntityManager().createQuery("SELECT MyTable FROM MyTable AS mytable WHERE " +
                    "mytable.someField=:firstParam AND mytable.secondField IS NOT NULL AND " +
                   // "AND mytable.otherTableValues"
                   , Share.class);
    q.setParameter(firstParam, firstVal);
    return q.getResultList();

所以不确定如何将consition放在otherTableValues上,因为它是列表类型。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

您必须加入该系列:

BindingSource