HHH-12419 - Incorrect batch inserts example

This commit is contained in:
Vlad Mihalcea 2018-03-22 14:22:51 +02:00
parent cb3d3c0fd7
commit 2903551b19
1 changed files with 4 additions and 4 deletions

View File

@ -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();