嗨我有一个两个实体,并通过使用onetomany关系单向映射。我将使用条件别名到父实体来编写查询,我想根据只有一些孩子在父实体中获取父列表childEntity,我写的是这样的。
Session session = HibernateUtil.getSessionFactory().openSession();
Criteria crit1 = session.createCriteria(RouteEntityClass.class);
crit1.add(Restrictions.eq("routeType", "Pick"));
crit1.createAlias("points", "point");
Criterion point1 = Restrictions.eq("point.pointAutoId", 26l);
Criterion pont2 = Restrictions.eq("point.pointAutoId", 27l);
LogicalExpression orExp = Restrictions.and(point1, pont2);
crit1.add(orExp);
List<RouteEntityClass> list = crit1.list();
for (RouteEntityClass rec : list) {
System.out.println("recccccccccccc" + rec.getRouteId());
}