@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 (COALESCE(:paymentStatuses, null) is null or ds.statusCode in :paymentStatuses)"
This solution will work for the empty list, null list, and a list with items 1 or more.