废话不多说直接贴代码

  1. Specification<Employee> employeeSpecification = new Specification<Employee>() {
  2. @Override
  3. public Predicate toPredicate(Root<Employee> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
  4. List<Predicate> predicateList = Lists.newArrayList();
  5. //isDelete
  6. Predicate isDeletePredicate = criteriaBuilder.or(criteriaBuilder.isNull(root.get("isDelete")),criteriaBuilder.equal(root.get("isDelete"),Constants.NOT_DELETE));
  7. predicateList.add(isDeletePredicate);
  8. //role_type 角色 为员工
  9. Predicate roleTypePredicate = criteriaBuilder.equal(root.get("roleType"),Constants.ROLE_TYPE_EMPLOYEE);
  10. predicateList.add(roleTypePredicate);
  11. //departmentId
  12. if(departmentId!=null){
  13. Predicate departmentPredicate = criteriaBuilder.equal(root.get("department").get("id"),departmentId);
  14. predicateList.add(departmentPredicate);
  15. }
  16. //去除已参加会议的人员 not in
  17. if(joinMeetingEmpIdList!=null&&!joinMeetingEmpIdList.isEmpty()){
  18. Predicate joinMeetingEmpIdListInPredicate = criteriaBuilder.not(root.get("id").in(joinMeetingEmpIdList));
  19. predicateList.add(joinMeetingEmpIdListInPredicate);
  20. }
  21. return criteriaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])).getRestriction();
  22. }
  23. };
  24. Pageable pageable = PageUtils.getPageable(pageIndex, pageSize);
  25. Page<Employee> page = this.employeeRespository.findAll(employeeSpecification, pageable);

Specification使用notin的更多相关文章

  1. JPA使用Specification构建动态查询

    封装Specification查询条件,在Spring Data JPA 2.0以前使用 Specifications 这个辅助类来操作where.not.and和or连接,在2.0版本以后这个类会被 ...

  2. 使用CocoaPods过程中 Unable to find a specification for

    文章转自:http://blog.csdn.net/zhangao0086/article/details/39703083 当把CocoaPods生成的workspace移动到上层目录时,需要改下P ...

  3. 规约模式Specification的学习

    最近一直在看DDD开发  规约似乎用得很普遍. 但是还是理解不了.所以记录下学习的进度.- 规约(Specification)模式 目的:查询语句和查询条件的分离 写了一个关于规约的模拟小程序 cla ...

  4. [.NET领域驱动设计实战系列]专题三:前期准备之规约模式(Specification Pattern)

    一.前言 在专题二中已经应用DDD和SOA的思想简单构建了一个网上书店的网站,接下来的专题中将会对该网站补充更多的DDD的内容.本专题作为一个准备专题,因为在后面一个专题中将会网上书店中的仓储实现引入 ...

  5. EF架构~引入规约(Specification)模式,让程序扩展性更强

    回到目录 规约(Specification)模式:第一次看到这东西是在microsoft NLayer项目中,它是微软对DDD的解说,就像petshop告诉了我们MVC如何使用一样,这个规约模式最重要 ...

  6. Tomcat7.0启动报错:java.lang.illegalargumentexception:taglib definition not consisten with specification version

    Tomcat7.0启动报错:java.lang.illegalargumentexception:taglib definition not consisten with specification ...

  7. The JSP specification requires that an attribute name is preceded by whitespace

    一个jsp页面在本地运行一点问题没有,发布到服务器就报错了: The JSP specification requires that an attribute name is preceded by ...

  8. 如何阅读《ECMAScript 2015 Language Specification》

    你不需要把<ECMAScript 2015 Language Specification>通读一遍,因为没那个必要.   阮一峰建议: 对于一般用户来说,除了第4章,其他章节都涉及某一方面 ...

  9. ORA-00119: invalid specification for system parameter LOCAL_LISTENER - 转

    错误分析 listener 可以正常启动: [oracle@o_target admin]$ cat listener.ora# listener.ora Network Configuration ...

随机推荐

  1. python mqtt通信(windows)

      一.消息队列服务器 这里我用到activemq,可到官网下载 http://activemq.apache.org/ 1. 若遇到点击apache-activemq-5.16.2\bin\acti ...

  2. FTP服务—三种登录类型的配置方法

    目录 一.部署 二.配置vsftpd 1.匿名用户登录配置 2.系统用户登录配置 3.虚拟用户登录配置 1. 创建虚拟用户名单文件 2. 生成虚拟用户口令认证文件 3. 创建FTP根目录及虚拟用户映射 ...

  3. C语言:最大公约数和最小公倍数

    #include <stdio.h> int main() { int a,b,c,m,t; printf("请输入两个数:\n"); scanf("%d%d ...

  4. C语言:读TXT 模拟键盘打字输出

    //#include<ctype.h> #include<stdio.h> #include <windows.h> //#include "string ...

  5. 00JAVA语法基础 原码、反码、补码

    记得之前学C语言的时候老师课上讲过一些,不过当时觉得考试不考,也就上课听了下,下课也没怎么多做了解.这次,Java课上再次提出来了,自己也超越了些资料,对这三种概念算是有所初步了解. 1.原码 数据储 ...

  6. C++:常量

    /** https://www.runoob.com/cplusplus/cpp-constants-literals.html * 常量: 固定值,一旦定义不能被修改 * 整数常量:可以是十进制.八 ...

  7. Maven工程 报 Diamond types are not supported at language level '5'

    Maven工程 报 Diamond types are not supported at language level '5' 出现这种信息,一般表示的是你的language level(IDEA下J ...

  8. Window安装构建神器Jenkins

    Jenkins是什么? Jenkins是一款开源 CI&CD 软件,用于自动化各种任务,包括构建.测试和部署软件.支持各种运行方式,可通过系统包.Docker 或者通过一个独立的 Java 程 ...

  9. Python自动化测试面试题-编程篇

    目录 Python自动化测试面试题-经验篇 Python自动化测试面试题-用例设计篇 Python自动化测试面试题-Linux篇 Python自动化测试面试题-MySQL篇 Python自动化测试面试 ...

  10. 深入刨析tomcat 之---第11篇 how tomcat works( 第15章 ) 如何解析web.xml 文件

    writedby 张艳涛 记得当年是学习jsp的时候,写过web.xml中的标签.在之后的springmvc中也是有关于配置mvc 过滤器 和dispatchServlet的标签,之前是看不懂呢!看到 ...