It depends on what you want to do in the batch job.
One approach could be to create a microflow to iterate all the data you want to process, pass this into the Java Action, and then mark the Java Action to run in a Task Queue. This will then iterate each item individually in its own transaction in the background.
https://docs.mendix.com/refguide/task-queue/
If this isn't want you need, can you give us some more information on the problem.
Good luck!