0
我使用Hibernate來從oracle.I獲取數據有標準對象進行的休眠過濾器中選擇這樣如何使用Hibernate
Criterion cr6=null;
if(reqrrn != null)
{
cr6=Restrictions.eq("rrn", reqrrn);//o
}
else{
cr6=Restrictions.like("rrn", "",MatchMode.ANYWHERE);
}
Criterion cr20=null;
if(cardPrefix != null && cardPrefix != "")
{
cr20=Restrictions.eq("prefix", cardPrefix);
}
else{
cr20=Restrictions.like("prefix", "",MatchMode.ANYWHERE);
}
criteria.add(Restrictions.and(cr6, cr20));
我有這樣的過濾器,以從數據庫中獲得空和填充值,但它是無用的,當值爲空時,例如 cardPrefix值在數據庫中爲空我想要獲得cardPrefix的所有值,這些填充和null也是如此,我怎麼能做到這一點?