According to the JavaDoc you linked to the second int parameter, this is not the maximum number to return, but
batchSize - if positive, - the number of objects for each batch sent back from db. All returned items will be returned. if batchSize <0, its hard limit and only 1 batch will be either batchSize or #, which correspond to the package
Maybe a negative number (-20) will do what you want, but I find the above statement is too confusing to be sure of that, so I would set batchSize to 20 and then filter in your application code.
Perhaps this is a file as an error / function request. There should be a way to specify skip / limit, which works the same way as on the shell interface. (Update: and there is another answer in the cursor class).
source share