spring data jpa 通過對象傳參


傳入的對象需要用@param注解修飾,value是查詢語句,countQuery是查詢總數,頁數語句

 @Query(nativeQuery = true, value = "select * from client " +
            "where type = 1 " +
            "and if(:#{#customer.bluury} is not null, company like CONCAT(:#{#customer.blurry},'%'),1=1) " +
            "and client.dept_id = :#{#customer.deptId} " +
            "and if(:#{#customer.principal} is not null,principal = :#{#customer.principal},1=1) " +
            "order by follow_time desc ",
            countQuery = "select count(1) from client " +
                    "where type = 1 " +
                    "and if(:#{#customer.bluury} is not null, company like CONCAT(:#{#customer.blurry},'%'),1=1) " +
                    "and client.dept_id = :#{#customer.deptId} " +
                    "and if(:#{#customer.principal} is not null,principal = :#{#customer.principal},1=1) " )
    Page<Client> findAllByDeptId(Pageable pageable,@Param("customer") CustomerQueryReq customer );


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM