@Query(value = \"Select f from Documents f \" + \"RIGHT JOIN f.documentStatus ds \" + \"where f.billingAccount.accountId in :billingAccountIdList \"
Try changing
" and ds.statusCode in :paymentStatuses"
into
" and (:paymentStatuses is null or ds.statusCode in :paymentStatuses)"