From 2903551b199700d873554ba548454becec8989de Mon Sep 17 00:00:00 2001 From: Vlad Mihalcea Date: Thu, 22 Mar 2018 14:22:51 +0200 Subject: [PATCH] HHH-12419 - Incorrect batch inserts example --- .../java/org/hibernate/userguide/batch/BatchTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/documentation/src/test/java/org/hibernate/userguide/batch/BatchTest.java b/documentation/src/test/java/org/hibernate/userguide/batch/BatchTest.java index 66c340d6c6..bb508114a1 100644 --- a/documentation/src/test/java/org/hibernate/userguide/batch/BatchTest.java +++ b/documentation/src/test/java/org/hibernate/userguide/batch/BatchTest.java @@ -200,15 +200,15 @@ public class BatchTest extends BaseEntityManagerFunctionalTestCase { int batchSize = 25; - for ( int i = 0; i < entityCount; ++i ) { - Person Person = new Person( String.format( "Person %d", i ) ); - entityManager.persist( Person ); - + for ( int i = 0; i < entityCount; i++ ) { if ( i > 0 && i % batchSize == 0 ) { //flush a batch of inserts and release memory entityManager.flush(); entityManager.clear(); } + + Person Person = new Person( String.format( "Person %d", i ) ); + entityManager.persist( Person ); } txn.commit();