Spring jpa添加查询条件

if ( StringUtils.isNotEmpty(companyId)){
current = criteriaBuilder.equal(root.get("companyId"),companyId);
result = criteriaBuilder.and(result,current);}

if (StringUtils.isNotEmpty(name)){
current = criteriaBuilder.like(root.get("name"),"%" + name + "%");
result = criteriaBuilder.and(result,current);}

posted @ 2021-04-28 16:41  聖凯  阅读(397)  评论(0编辑  收藏  举报