I have a question/confusion, how to do batch insert when records are in odd number say for example
batchSize = 20;
em.getTransaction().begin();
for (int i = 0; i < 23; i++){
Book book = new Book(i, "JPA Batch Insert Example: " + i);
em.persist(book);
if (i % batchSize == 0 && i > 0) {
em.flush();
em.clear();
}
}
em.getTransaction().commit();
In this example 20 records will be inserted at once but what about rest 3 records what will happen to those 3 records , will it insert if yes then when