How to skip @Param in @Query if is null or empty in Spring Data JPA

后端 未结 2 1226
逝去的感伤
逝去的感伤 2021-01-18 08:39
@Query(value = \"Select f from Documents f \" +
        \"RIGHT JOIN f.documentStatus ds \" +
        \"where f.billingAccount.accountId  in :billingAccountIdList \"         


        
2条回答
  •  北恋
    北恋 (楼主)
    2021-01-18 09:11

    Try changing

    " and ds.statusCode in :paymentStatuses"
    

    into

    " and (:paymentStatuses is null or ds.statusCode in :paymentStatuses)"
    

提交回复
热议问题