criteria用法

 criteria中or

criteria.add(Restrictions.or(Restrictions.eq("woId",workOrderQueryReq.getDemolitionOrderId())));

String tel = customerQueryReq.getCallNumber();

//      String sql = "cust_Id in ( select cust_id from address where cust_mobile = '"+customerQueryReq.getCallNumber()+"')";
// String sql = "cust_Id in ( select cust_id from address where cust_mobile = '"+tel+"' or contact_tel = '"+tel
// +"' or addr_message_mobile = '"+tel+"' or addr_bind_phone = '"+tel+"')";
// c.add(Restrictions.or(Restrictions.sqlRestriction(sql),Restrictions.eq("custMobile", customerQueryReq.getCallNumber())));
String sql = "CUST_MOBILE = '"+tel+"' or UNIT_TEL = '"+tel+"')";
c.add(Restrictions.sqlRestriction(sql));


criteria中in

//手机号
if(StringUtil.isNotBlank(accountReq.getCustMobile())){
String sql = " addr_id in (SELECT addr_id from address cc where cc.cust_mobile = '"+accountReq.getCustMobile()+"')";
criteria.add(Restrictions.sqlRestriction(sql));
}

//身份证号
if(StringUtils.isNotBlank(accountReq.getIdno())){
String sql = " cust_id in (SELECT cust_id from customer c where c.certificate_no = '"+accountReq.getIdno()+"')";
criteria.add(Restrictions.sqlRestriction(sql));
}

原文地址:https://www.cnblogs.com/flymili1017/p/11088556.html