Springboot jpa and orマージクエリー

1114 ワード

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 ?