springboot jpa and or 合并 一起 查询

List list = new ArrayList();
List integers = recursionData(new ArrayList<>(), Collections.singletonList(user.getManagementArea()));
Path path = root.get("dept");
CriteriaBuilder.In in = criteriaBuilder.in(path);
integers.forEach(in::value);
Predicate or = criteriaBuilder.like(root.get("feedbackUserId").as(String.class), userId);
//重点
list.add(criteriaBuilder.or(in, or)); 
  

 

 

//执行sql

Hibernate: select feedback0_.id as id1_2_, feedback0_.context as context2_2_, feedback0_.create_time as create_t3_2_, feedback0_.dept as dept4_2_, feedback0_.feedback_user as feedback5_2_, feedback0_.feedback_user_id as feedback6_2_, feedback0_.title as title7_2_, feedback0_.update_time as update_t8_2_ from tbl_feedback feedback0_ where feedback0_.dept in (14 , 15) or cast(feedback0_.feedback_user_id as char) like ? order by feedback0_.create_time desc limit ?
 

你可能感兴趣的:(SpringBoot)