我遇到了以下问题:
我有三个类,每个类在我的数据库上映射一个表。情况如下:
class A{
Integer id;
String name;
Set<AB> ab = new HashSet<AB>(0);
//getter and setter
}
class AB{
Integer id;
A a;
B b;
//getter and setter
}
class B{
Integer id;
String name;
Set<AB> ab = new HashSet<AB>(0);
//getter and setter
}
我想实现使用Hibernate Criteria,以下查询:
" Select * from B b join b.ab where ab.a.id in (id1 or id2 or id3)".
换句话说,我想在where子句中,至少有一个元素。我尝试过这样的事情:
Session session = entityManager.unwrap(Session.class);
Criteria criteria = session.createCriteria(B.class);
criteria.add(Restrictions.in(ab, input.getAb));
但它看起来并不像预期的那样起作用,似乎它正在寻找该组的所有对象都是等于。
解决这个问题的一些提示?
提前致谢