使用DetachedCriteria 模糊查询中值为null时的情况

来源:互联网 发布:linux进程间通讯机制 编辑:程序博客网 时间:2024/06/06 02:07
当时用DetachedCriteria

 进行模糊查询的时候若传递来的参数为null  在debug模式下发现参数为%% 但是却查询不到数据


所以使用参数传递查询的时候需要先判断参数是否为空值;


if(StringUtils.isNotBlank(customer.getCust_name())){
            dc.add(Restrictions.like("cust_name", "%"+customer.getCust_name()+"%"));
        }



阅读全文
0 0
原创粉丝点击