当前位置:   article > 正文

jpa中使用Query判断条件查询

jpa 条件判断

jpa中使用Query判断条件查询

  1. @Query(value = " select m.* from mining_area as m " +
  2. " where 1 = 1" +
  3. " and if(:name != '' , m.name like :name , 1 = 1) " +
  4. " and if(IFNULL(:startDate, '') != '' , DATE(m.create_time) > DATE(:startDate) , 1 = 1 ) " +
  5. " and if(IFNULL(:endDate, '') != '' , DATE(m.create_time) < DATE(:endDate) , 1 = 1 ) " +
  6. " and if(IFNULL(:status, '') != '' , m.audit_status = :status , 1 = 1 ) " +
  7. " and m.deleted = :deleted " +
  8. " and ( m.tree_code like :treeCode and m.audit_status = 3 )" +
  9. " or ( m.tree_code = :noLikeTreeCode ) ",
  10. countQuery = " select count(m.*) from mining_area as m " +
  11. " where 1 = 1" +
  12. " and if(:name != '' , m.name like :name , 1 = 1) " +
  13. " and if(IFNULL(:startDate, '') != '' , DATE(m.create_time) > DATE(:startDate) , 1 = 1 ) " +
  14. " and if(IFNULL(:endDate, '') != '' , DATE(m.create_time) < DATE(:endDate) , 1 = 1 ) " +
  15. " and if(IFNULL(:status, '') != '' , m.audit_status = :status , 1 = 1 ) " +
  16. " and m.deleted = :deleted " +
  17. " and ( m.tree_code like :treeCode and m.audit_status = 3 )" +
  18. " or ( m.tree_code = :noLikeTreeCode ) ",
  19. nativeQuery = true)
  20. List<MiningArea> findPage(String name, Date startDate, Date endDate, AreaAuditStatusEnum status,
  21. String treeCode, String noLikeTreeCode , Integer deleted, Pageable pageable);
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/爱喝兽奶帝天荒/article/detail/974888
推荐阅读
相关标签
  

闽ICP备14008679号