...
Once the solution is implemented, these tests will be updated to show that no exception is thrown, with even more items e.g. 40,000.
Proposal #1:
...
Batching at 32,000
This solution adds a wrapper method that partitions the input collection into lists of 32,000 and calls the original repository method on each batch:
...
If a public method takes in a Collection (and not a List), then either an ArrayList copy of the Collection is needed, or the public API method needs to be changes to List, as Lists.partition requires a List to partition.
Batching on repository methods versus API methods
This solution could also work equally well batching at the public API methods instead of each repository method (probably).
Proposal #2: Postgres arrays
...