实际中有sql如下: where transportType=1 and ((pol=1 and pod=2) or (pol=1 and pod=3) or (pol=1 and pod=4))
Criteria criteria = getCriteria();
if(transportType!=null)criteria.add(Restrictions.eq("transportType", transportType));
if(polIdStr!=null && podIdStr!=null) {
List<Integer> polIdList = ListUtil.stringToList(polIdStr);
List<Integer> podIdList = ListUtil.stringToList(podIdStr);
List<Criterion> CriterionList=new ArrayList<Criterion>();
Disjunction dis = Restrictions.disjunction();//多个or可以拼蛸
for(int polId:polIdList){
for(int podId:podIdList){
Conjunction con=Restrictions.conjunction();//多个and拼接
con.add(Restrictions.eq("polId", polId));
con.add(Restrictions.eq("podId", podId));
dis.add(con);
}
}
criteria.add(dis);
}