How Hibernate Batch insert works?

前端 未结 3 1531
攒了一身酷
攒了一身酷 2021-01-20 04:07

Can some one explain me how

hibernate.jdbc.batch_size=1000 

and

if (i % 100 == 0 && i>0) {
                           


        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-20 05:07

    hibernate.jdbc.batch_size determines the maximum batch size that is executed. If implicit or explicit flush is performed before the specified batch size is reached (the number of pending insert or update statements for the same table), all pending statements are packed in one batch, and the 'accumulation' of statements is restarted.

    So, in your example you would execute batches consisting of 100 statements each. Or, for example, if the batch size were 100 and the modulo divider were 500, when the flush operation occurs you would execute 5 batches consisting of 100 statements each.

提交回复
热议问题