首页 > 其他 > 详细

jpa中使用Query判断条件查询

时间:2020-09-19 20:49:28      阅读:1630      评论:0      收藏:0      [点我收藏+]

jpa中使用Query判断条件查询

@Query(value = " select m.* from mining_area as m " +
            " where 1 = 1" +
            " and if(:name != ‘‘ , m.name like :name , 1 = 1) " +
            " and if(IFNULL(:startDate, ‘‘) != ‘‘ , DATE(m.create_time) > DATE(:startDate) , 1 = 1 ) " +
            " and if(IFNULL(:endDate, ‘‘) != ‘‘ , DATE(m.create_time) < DATE(:endDate) , 1 = 1 ) " +
            " and if(IFNULL(:status, ‘‘) != ‘‘ , m.audit_status = :status , 1 = 1 ) " +
            " and m.deleted = :deleted " +
            " and ( m.tree_code like :treeCode and m.audit_status = 3  )" +
            " or ( m.tree_code = :noLikeTreeCode  ) ",
        countQuery = " select count(m.*) from mining_area as m " +
                " where 1 = 1" +
                " and if(:name != ‘‘ , m.name like :name , 1 = 1) " +
                " and if(IFNULL(:startDate, ‘‘) != ‘‘ , DATE(m.create_time) > DATE(:startDate) , 1 = 1 ) " +
                " and if(IFNULL(:endDate, ‘‘) != ‘‘ , DATE(m.create_time) < DATE(:endDate) , 1 = 1 ) " +
                " and if(IFNULL(:status, ‘‘) != ‘‘ , m.audit_status = :status , 1 = 1 ) " +
                " and m.deleted = :deleted " +
                " and ( m.tree_code like :treeCode and m.audit_status = 3  )" +
                " or ( m.tree_code = :noLikeTreeCode  ) ",
        nativeQuery = true)
    List<MiningArea> findPage(String name, Date startDate, Date endDate, AreaAuditStatusEnum status,
                              String treeCode, String noLikeTreeCode , Integer deleted, Pageable pageable);

jpa中使用Query判断条件查询

原文:https://www.cnblogs.com/GoslingWu/p/13697326.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!