@Query(value = "Select f from Documents f " +
"RIGHT JOIN f.documentStatus ds " +
"where f.billingAccount.accountId in :billingAccountIdList " +
" and ds.statusCode in :paymentStatuses" +
" and f.paymentDate < :paymentDate")
List<FinancialDocumentEntity> getFinancialDocumentsOverdue(@Param("billingAccountIdList")List<String> billingAccountIdList,
@Param("paymentStatuses") List<String> paymentStatuses,
@Param("paymentDate") Date paymentDate);
我有上面的查询。是否可以在查询方法中跳过搜索参数,例如 @Param("paymentStatuses")
如果为 null 或为空?
最佳答案
尝试改变
" and ds.statusCode in :paymentStatuses"
进入
" and (:paymentStatuses is null or ds.statusCode in :paymentStatuses)"
关于java - 如果在 Spring Data JPA 中为 null 或为空,如何在 @Query 中跳过 @Param,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46789664/