hql用到or时的问题
String hql0 = "select m from Materials m,Bill b1,Bill b2 where b1.billtype = 'ENTER' and b2.billtype = 'EXIT' and m in elements(b1.materials) or m in elements(b2.materials) ";
本hql语句在b2不为null时能得到正确的结果,但是当b2为null时得到的结果页为nul,我要得到的结果是在b2为null时得到正确的结果
------解决方案--------------------
String hql0 = "";
if(b2 != null){
hql0 = "select m from Materials m,Bill b1,Bill b2 where b1.billtype = 'ENTER' and b2.billtype = 'EXIT' and m in elements(b1.materials) or m in elements(b2.materials) ";
}else{
hql0 = "select m from Materials m,Bill b1,Bill b2 where b1.billtype = 'ENTER' and b2.billtype = 'EXIT' and m in elements(b1.materials)
}