You have a bit of code to insert records into the database that accumulates the value groups into a batch and submits them all at once, presumably returning all the generated primary key IDs. (entity.internal and clause.internal, do-prepared-insert)
I don't know if you're aware, but only one database supports this functionality, MySQL. Oracle, PostgreSQL, and DB2 generate error messages when you try to run this code. If you want to support more than MySQL, you need to make individual execute() calls and accumulate the resulting IDs.