Hibrenate Criteria 查询

Session session = this.getSessionFactory().getCurrentSession();
        Criteria criteria = session.createCriteria(DisInfo.class, "d");
        criteria.createAlias("d.resources", "r", Criteria.INNER_JOIN);
        criteria.add(Restrictions.in("r.area.id", new Integer[]{3,5}));
        criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); //去掉重复
        return (List<DisInfo>)criteria.list();

 

你可能感兴趣的:(Hibrenate Criteria 查询)